Plugin Directory

Changeset 1541826


Ignore:
Timestamp:
11/28/2016 10:01:14 AM (9 years ago)
Author:
etemplates
Message:

1.4 Release

Location:
ect-seo/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • ect-seo/trunk/index.php

    r1143046 r1541826  
    22/*
    33    Plugin Name:ECT SEO
    4     Plugin URI: http://www.ecommercetemplates.com/wordpress/wp-plugins.asp
     4    Plugin URI: http://www.ecommercetemplates.com//wp-plugins.asp
    55    Description:This plugin will automatically add meta description tags and will set title the for all ECT store pages.
    66    Author:Andy Chapman
    77    Author URI:http://www.ecommercetemplates.com
    8     Version:1.3
     8    Version:1.4
    99*/
    10 function ect_seo_fun($arr)
     10
     11add_filter('pre_get_document_title', 'filter_pagetitle',10,1);
     12add_action('wp_head', 'add_cs_meta',1);
     13add_shortcode('ect_seo','ect_seo_fun_short');
     14
     15function ect_seo_fun_short()
     16{
     17    remove_action('wp_head','_wp_render_title_tag',1);
     18    remove_action('wp_head','add_cs_meta',1);
     19    $T=ect_seo_fun('t') ;
     20    echo '<title>'.$T.'</title>';
     21    add_cs_meta();
     22}
     23function filter_pagetitle($title)
     24{
     25    $Ttl=ect_seo_fun('t');
     26    return $Ttl;
     27}
     28function add_cs_meta()
     29{
     30    $Meta=ect_seo_fun('m');
     31    echo '<meta name="Description" content="'.$Meta.'" />';
     32}
     33function GetCatInfoPDetail($PID)
     34{   
     35    global $db_username,$db_password,$db_name,$db_host,$ECTWPDB,$productid;
     36
     37    if(!empty($db_username) && !empty($PID))   
     38    {       
     39        $SiteRoot=WP_CONTENT_DIR;       
     40        include_once $SiteRoot."/../vsadmin/includes.php";     
     41        include_once $SiteRoot."/../vsadmin/db_conn_open.php"; 
     42        if(!$ECTWPDB)       
     43        {   
     44            $ECTWPDB=new wpdb($db_username, $db_password, $db_name, $db_host);
     45            $PArr=$ECTWPDB->get_row("select pID,pName,pSection from products where pID='".$PID."'");
     46        $Cats=$ECTWPDB->get_row("select sectionName,topsection from sections where sectionID=".$PArr->pSection);        $Cats1=$ECTWPDB->get_row("select sectionName from sections where sectionID=".$Cats->topsection);           
     47
     48            $Data=array(
     49            'PName'=>$PArr->pName,
     50            'PId'=>$PArr->pID,                 
     51            'SecName'=>$Cats->sectionName, 
     52            'CatName'=>$Cats1->sectionName
     53            ); 
     54            return $Data;       
     55        }       
     56    }
     57}
     58function GetCatName($CatID,$Sec='')
     59{
     60    global $db_username,$db_password,$db_name,$db_host,$ECTWPDB;
     61
     62    if(!empty($db_username) && !empty($CatID))
     63    {
     64        $SiteRoot=WP_CONTENT_DIR;
     65        include_once $SiteRoot."/../vsadmin/includes.php";
     66        include_once $SiteRoot."/../vsadmin/db_conn_open.php";
     67        if(!$ECTWPDB)
     68        {
     69            $ECTWPDB=new wpdb($db_username, $db_password, $db_name, $db_host);
     70        }
     71        //$Tbls=$ECTWPDB->get_results("show tables");
     72        if(empty($Sec))
     73        {
     74            $Cats=$ECTWPDB->get_row("select sectionName from sections where sectionID=".$CatID);
     75            if(!empty($Cats))
     76                return $Cats->sectionName;
     77        }
     78        else
     79        {
     80            $Cats=$ECTWPDB->get_row("select topSection from sections where sectionID=".$CatID);         
     81            if(!empty($Cats))
     82            {
     83                $Cats1=$ECTWPDB->get_row("select sectionName,topSection from sections where sectionID=".$Cats->topSection);
     84                if(!empty($Cats1))                  return $Cats1->sectionName;
     85            }
     86        }
     87       
     88    }
     89    return $CatID;
     90}
     91function ect_seo_fun($m)
    1192{   
    1293    $Title=$Meta=$Key='';
    13     global $pagetitle,$topsection,$sectionname,$sectiondescription,$productname,$productid,$productdescription;
     94    global $pagetitle,$topsection,$sectionname,$sectiondescription,$productname,$productid,$productdescription,$usecategoryname;
     95    $DataArrTemp=array($pagetitle,$topsection,$sectionname,$sectiondescription,$productname,$productid,$productdescription);
     96
     97    $BlogInfo=esc_attr(get_bloginfo('name', 'display')) ;
     98    if(is_front_page() || is_home())
     99    {
     100        return GenerateSeoTags('front_page',$Title,$Meta,$Key,$m);
     101    }
     102   
    14103    if(@$GLOBALS['ectcartpage']=='proddetail')
    15104    {       
    16         $Cat=isset($_GET['prod']) ? $_GET['prod'] : '';     
     105        $Pod=isset($productid) ? $productid : $_GET['prod'];
     106        $PTitleInfo=GetCatInfoPDetail($Pod);
     107
    17108        $Title=esc_attr(get_bloginfo('name', 'display')).' store: '.$productname. " | " . $sectionname. " | " . $productid;     
    18109        $Srh=array('%SHOW_BLOG_NAME%','%PROD_NAME%','%SEC_NAME%','%PROD_ID%','%CAT_NAME%');
    19110        $BlogInfo=esc_attr(get_bloginfo('name', 'display')) ;
    20        
    21 
    22         $Rep=array($BlogInfo,$productname,$sectionname,$productid,$Cat);       
    23        
     111        $productname=empty($productname) ? $PTitleInfo['PName'] : $productname;
     112        $sectionname=empty($sectionname) ? $PTitleInfo['SecName'] : $sectionname;
     113
     114        $productid=empty($productid) ? $PTitleInfo['PId'] : $productid;
     115        $topsection=empty($topsection) ? $PTitleInfo['CatName'] : $topsection;
     116
     117        $Rep=array($BlogInfo,$productname,$sectionname,$productid,$topsection);
    24118        $Frm=get_option('ect_seo_pdts',true);               
    25119        $Title=str_replace($Srh,$Rep,$Frm);         
    26120        $Meta=str_replace('"','&quot;',$productdescription);
    27         return GenerateSeoTags('proddetail',$Title,$Meta,'');
     121        return GenerateSeoTags('proddetail',$Title,$Meta,$Key,$m);
    28122    }
    29123    elseif(@$GLOBALS['ectcartpage']=='products' )
    30124    {
    31         $Cat=isset($_GET['cat']) ? $_GET['cat'] : '';
     125        $Cat=GetCatName($_GET['cat']);
     126        $SecName=GetCatName($_GET['cat'],'sec');
    32127    //  $Title=esc_attr(get_bloginfo('name', 'display')).' store: ';
    33128       
    34129        $Srh=array('%SHOW_BLOG_NAME%','%PROD_NAME%','%SEC_NAME%','%PROD_ID%','%CAT_NAME%');
    35130        $BlogInfo=esc_attr(get_bloginfo('name', 'display')) ;
    36         $Rep=array($BlogInfo,$productname,$sectionname,$productid,$Cat);
    37         $Frm=get_option('ect_seo_pts',true);
    38         $Title=str_replace($Srh,$Rep,$Frm);
    39        
     131
     132        $sectionname=empty($sectionname) ? $SecName : $sectionname;
     133        $topsection=empty($topsection) ? $Cat : $topsection;
     134
     135        $Rep=array($BlogInfo,$productname,$sectionname,$productid,$topsection);     
     136        $Frm=get_option('ect_seo_pts',true);        $Title=str_replace($Srh,$Rep,$Frm);
     137   
    40138        /*if($topsection!= "")
    41139            $Title=$Title.$topsection . ",3 ";
     
    43141        $Meta=str_replace('"','&quot;',$sectiondescription);
    44142       
    45        
    46         return GenerateSeoTags('products',$Title,$Meta,'');
     143
     144        return GenerateSeoTags('products',$Title,$Meta,$Key,$m);
    47145    }
    48146    elseif(@$GLOBALS['ectcartpage']=='categories')
    49147    {
    50         $Cat=isset($_GET['cat']) ? $_GET['cat'] : '';
    51         $Title=esc_attr(get_bloginfo('name', 'display')).' store: ';
    52             if($topsection!= "")
    53                 $Title=$Title.$topsection. ", ";
    54             $Title=$Title.$sectionname;
     148        $Cat=GetCatName($_GET['cat']);
     149        $SecName=GetCatName($_GET['cat'],'sec');
     150        //$Title=esc_attr(get_bloginfo('name', 'display')).' store: ';
     151        //  if($topsection!= "")
     152        //      $Title=$Title.$topsection. ", ";
     153        //  $Title=$Title.$sectionname;
    55154        $Meta=str_replace('"','&quot;',$sectiondescription);
    56        
     155   
    57156        $Srh=array('%SHOW_BLOG_NAME%','%PROD_NAME%','%SEC_NAME%','%PROD_ID%','%CAT_NAME%');
    58157        $BlogInfo=esc_attr(get_bloginfo('name', 'display')) ;
    59         $Rep=array($BlogInfo,$productname,$sectionname,$productid,$Cat);
    60         $Frm=get_option('ect_seo_cts',true);
    61         $Title=str_replace($Srh,$Rep,$Frm);
    62        
    63         return GenerateSeoTags('categories',$Title,$Meta,'');
     158
     159        $topsection=!empty($topsection ) ? $topsection : $Cat;
     160
     161        $sectionname=$sectionname; 
     162        if(!$sectionname)
     163            $sectionname=$SecName;
     164        $Rep=array($BlogInfo,$productname,$sectionname,$productid,$topsection);
     165        $Frm='%CAT_NAME% | %SHOW_BLOG_NAME% ';
     166        $Title=str_replace($Srh,$Rep,$Frm);
     167        if($topsection)
     168            return GenerateSeoTags('categories',$Title,$Meta,$Key,$m,1);
     169        else
     170            return GenerateSeoTags('categories','','','',$m);
    64171    }
    65172    elseif(@$GLOBALS['ectcartpage']=='cart')
     
    68175        $Meta   ='Online store shopping cart and checkout for '.esc_attr(get_bloginfo('name', 'display'));
    69176        $Key    ='';
    70         return GenerateSeoTags('cart',$Title,$Meta,$Key);
     177        return GenerateSeoTags('cart',$Title,$Meta,$Key,$m).' - '.$BlogInfo;
    71178    }
    72179    elseif(@$GLOBALS['ectcartpage']=='affiliate')
     
    74181        $Title='Affiliate program for '.esc_attr(get_bloginfo('name', 'display'));
    75182        $Meta=esc_attr(get_bloginfo('name', 'display')).' affiliate program';
    76         return GenerateSeoTags('affiliate',$Title,$Meta);
     183        return GenerateSeoTags('affiliate',$Title,$Meta,$Key,$m).' - '.$BlogInfo;
    77184    }
    78185    elseif(@$GLOBALS['ectcartpage']=='clientlogin')
     
    80187        $Title='Customer account for '.esc_attr(get_bloginfo('name', 'display'));
    81188        $Meta=esc_attr(get_bloginfo('name', 'display')).' client login';
    82         return GenerateSeoTags('clientlogin',$Title,$Meta);
     189        return GenerateSeoTags('clientlogin',$Title,$Meta,$Key,$m).' - '.$BlogInfo;
    83190    }
    84191    elseif(@$GLOBALS['ectcartpage']=='giftcertificate')
     
    86193        $Title='Purchase a gift certificate from '.esc_attr(get_bloginfo('name', 'display'));
    87194        $Meta=esc_attr(get_bloginfo('name', 'display')).' gift certificates';
    88         return GenerateSeoTags('giftcertificate',$Title,$Meta);
     195        return GenerateSeoTags('giftcertificate',$Title,$Meta,$Key,$m).' - '.$BlogInfo;
    89196    }
    90197    elseif(@$GLOBALS['ectcartpage']=='orderstatus')
     
    92199        $Title='Check the status of your order on '.esc_attr(get_bloginfo('name', 'display'));
    93200        $Meta=esc_attr(get_bloginfo('name', 'display')).' order status';
    94         return GenerateSeoTags('orderstatus',$Title,$Meta);
     201        return GenerateSeoTags('orderstatus',$Title,$Meta,$Key,$m).' - '.$BlogInfo;
    95202    }
    96203    elseif(@$GLOBALS['ectcartpage']=='search')
     
    98205        $Title='Search for products on '.esc_attr(get_bloginfo('name', 'display'));
    99206        $Meta=esc_attr(get_bloginfo('name', 'display')).' search';
    100         return GenerateSeoTags('search',$Title,$Meta);
     207        return GenerateSeoTags('search',$Title,$Meta,$Key,$m).' - '.$BlogInfo;
    101208    }
    102209    elseif(@$GLOBALS['ectcartpage']=='sorry')
     
    104211        $Title='Sorry - there seems to be a problem with the order';
    105212        $Meta='Sorry - there seems to be a problem with the order';
    106         return GenerateSeoTags('sorry',$Title,$Meta);
     213        return GenerateSeoTags('sorry',$Title,$Meta,$Key,$m).' - '.$BlogInfo;
    107214    }
    108215    elseif(@$GLOBALS['ectcartpage']=='thanks')
     
    110217        $Title='Thank you for purchasing from '.esc_attr(get_bloginfo('name', 'display'));
    111218        $Meta=esc_attr(get_bloginfo('name', 'display')).' confirmation page';
    112         return GenerateSeoTags('thanks',$Title,$Meta);
     219        return GenerateSeoTags('thanks',$Title,$Meta,$Key,$m).' - '.$BlogInfo;
    113220    }
    114221    elseif(@$GLOBALS['ectcartpage']=='tracking')
     
    116223        $Title='Track your purchase from '.esc_attr(get_bloginfo('name', 'display'));
    117224        $Meta=esc_attr(get_bloginfo('name', 'display')).' tracking page';
    118         return GenerateSeoTags('tracking',$Title,$Meta);
    119     }
    120     elseif(is_front_page()){
    121        
    122         return GenerateSeoTags('front_page',$Title,$Meta,'');
     225        return GenerateSeoTags('tracking',$Title,$Meta,$Key,$m).' - '.$BlogInfo;
    123226    }
    124227    else
    125     {
    126        
    127         if ( defined( 'WPSEO_VERSION' ) ) {
    128             // WordPress SEO is activated
    129                 $Title=wp_title('',false);
    130             return GenerateSeoTags('',$Title,'');       
    131 } else {
    132                 // WordPress SEO is not activated
    133             $Title=wp_title( '&#124;', false, 'right' );
    134                 return GenerateSeoTags('',$Title,'');       
    135 }
    136     }
    137 }
    138 add_shortcode('ect_seo','ect_seo_fun');
     228        return GenerateSeoTags('',$Title,$Meta,$Key,$m).' - '.$BlogInfo;
     229}
    139230add_action('admin_menu','ect_seo_nav');
    140231function ect_seo_nav()
     
    161252            <li>
    162253                <label><?php echo ucfirst(str_replace('_',' ',$P));?></label>
    163                 <input type="text" name="seo_data_title[<?php echo $p?>]" value="<?php echo stripslashes(get_option('ect_seo_'.$P.'_title'))?>" />
    164                 <input type="text" name="seo_data_metacnt[<?php echo $p?>]" value="<?php echo stripslashes(get_option('ect_seo_'.$P.'_meta_description'))?>" />
     254                <input type="text" name="seo_data_title[<?php echo $P?>]" value="<?php echo stripslashes(get_option('ect_seo_'.$P.'_title'))?>" />
     255                <input type="text" name="seo_data_metacnt[<?php echo $P?>]" value="<?php echo stripslashes(get_option('ect_seo_'.$P.'_meta_description'))?>" />
    165256            </li>   
    166            
     257
    167258            <?php endif;?>
    168259            <?php endforeach;?>
     
    173264                <label>Product Detail Page </label>
    174265                <input type="text" name="pdts" value="<?php echo get_option('ect_seo_pdts',true)?>" style="width:666px"/><br />
    175                 <code class="code">%SHOW_BLOG_NAME% store: %PROD_NAME% | %SEC_NAME% | %PROD_ID% | %CAT_NAME% </code>   
     266                <code class="code">%SHOW_BLOG_NAME% store | %PROD_NAME% | %SEC_NAME% | %PROD_ID% | %CAT_NAME% </code>   
    176267            </li>
    177268            <li>               
    178269                <label>Product Page </label>   
    179270                <input type="text" name="pts" value="<?php echo get_option('ect_seo_pts',true)?>" style="width:666px"/><br />
    180                 <code class="code">%SHOW_BLOG_NAME% store: %PROD_NAME% | %SEC_NAME% | %PROD_ID% | %CAT_NAME% </code>   
     271                <code class="code">%SHOW_BLOG_NAME% store |: %SEC_NAME% | %CAT_NAME% </code>   
    181272            </li>
    182273            <li>               
    183274                <label>Category Page </label>   
    184275                <input type="text" name="cts" value="<?php echo get_option('ect_seo_cts',true)?>" style="width:666px"/><br />
    185                 <code class="code">%SHOW_BLOG_NAME% store: %PROD_NAME% | %SEC_NAME% | %PROD_ID% | %CAT_NAME% </code>   
     276                <code class="code">%SHOW_BLOG_NAME% store | %SEC_NAME% | %CAT_NAME% </code>
    186277            </li>
    187278            <li><input type="submit" value="Update Settings"/>
     
    220311            for($i=0;$i<count($_POST['seo_data_title']);$i++)
    221312            {
    222                 update_option('ect_seo_'.$PagesArr2[$i].'_title',$_POST['seo_data_title'][$i]);
    223                 update_option('ect_seo_'.$PagesArr2[$i].'_meta_description',$_POST['seo_data_metacnt'][$i]);
     313                update_option('ect_seo_'.$PagesArr2[$i].'_title',$_POST['seo_data_title'][$PagesArr2[$i]]);
     314                update_option('ect_seo_'.$PagesArr2[$i].'_meta_description',$_POST['seo_data_metacnt'][$PagesArr2[$i]]);
    224315            }
    225316            echo '<script type="text/javascript">window.location="admin.php?page=ect_seo&msg=1"</script>';
    226317        }
    227        
    228     }
    229 }
    230 
    231 function GenerateSeoTags($P,$DefTitle='',$DefDesc='',$DefKey='')
    232 {
     318   
     319    }
     320}
     321
     322function GenerateSeoTags($P,$DefTitle='',$DefDesc='',$DefKey='',$type='t',$Off=false)
     323{
     324
    233325    global $post;
    234326        global $pagetitle,$topsection,$sectionname,$sectiondescription,$productname,$productid,$productdescription;
     
    236328        $Meta=get_option('ect_seo_'.$P.'_meta_description');
    237329        $Key=get_option('ect_seo_'.$P.'_meta_keywords');
    238         if($P=='categories' || $P=='products')
     330        if($P=='products' || $P=='categories')
    239331        {
    240332            if(empty($pagetitle) && isset($_GET['cat']) && !empty($_GET['cat']))
    241333                $Title=$Meta='';
    242334        }
     335        if($Off)
     336            $Title='';
    243337        $Title  =!empty($Title) ? $Title : $DefTitle;
    244338        $Meta   =!empty($Meta) ? $Meta : $DefDesc;
     
    250344            $Title=$Title1;
    251345        if(!empty($post->ID) && !empty($Meta1))
    252             $Meta=$Meta1;
     346
     347        $Meta=$Meta1;
    253348    //echo $productname;
    254    
     349    if(empty($Title))
     350        $Title=$post->post_title;
    255351    $T  =str_replace("%SHOW_BLOG_NAME%",$BlogInfo,$Title);
    256352    $M  =str_replace("%SHOW_BLOG_NAME%",$BlogInfo,$Meta);
    257353    $K  =str_replace("%SHOW_BLOG_NAME%",$BlogInfo,$Key);
    258     if(empty($P))
    259     {
    260             return '    <title>'.$T.'</title>
    261             <meta name="Description" content="'.$M.'" /> ';
    262     }       
     354
     355
     356   
    263357    $DynamicMetaPages=array('proddetail','products','categories');
    264     if(!empty($pagetitle))
     358    if($P=='front_page')
     359        return ($type=='t') ? $T : $M;
     360    elseif(!empty($Title))
    265361    {
    266362        if(in_array($P,$DynamicMetaPages)) 
    267363        {   
    268364            $DescP=($P!='proddetail') ? $sectiondescription : $productdescription;     
    269             if(!empty($pagetitle))     
     365            if(!empty($Title))     
    270366            {           
    271                 $Srh=array('%SHOW_BLOG_NAME%','%PROD_NAME%','%SEC_NAME%','%PROD_ID%','%CAT_NAME%');
    272                 $BlogInfo=esc_attr(get_bloginfo('name', 'display')) ;
    273                 $Rep=array($BlogInfo,$productname,$sectionname,$productid,$Cat);
    274                 return "<title>".$pagetitle."</title>           
    275                 <meta name='Description' content='".str_replace('"','&quot;',$DescP)."' >";     
     367                //$Srh=array('%SHOW_BLOG_NAME%','%PROD_NAME%','%SEC_NAME%','%PROD_ID%','%CAT_NAME%');
     368                //$BlogInfo=esc_attr(get_bloginfo('name', 'display'))   ;
     369                //$Rep=array($BlogInfo,$productname,$sectionname,$productid,$Cat);
     370                return ($type=='t') ? $T : $M; 
    276371            }       
    277372            else       
     
    284379                        $ts=$productname . ", " . $sectionname;         
    285380                }           
    286                 return "<title>".$BlogInfo." store: ".$ts."</title>         
    287                 <meta name='Description' content='".str_replace('"','&quot;',$DescP)."' >";     
     381                return ($type=='t') ? $T : $M;
    288382            }                   
    289383        }
    290     }   
    291     else   
    292     {
    293         return '    <title>'.$T.'</title>
    294             <meta name="Description" content="'.$M.'" /> '; }       
     384        else
     385            return ($type=='t') ? $T : $M;
     386    }       
     387    else
     388    {
     389   
     390        return ($type=='t') ? $T : $M; 
     391    }
    295392}
    296393add_action( 'add_meta_boxes', 'ect_seo_box_fun' );
     
    310407            <input type="text" name="ect_seo_title" value="'.get_option('ect_seo_'.$post->ID.'_title').'"/>
    311408        </li>
     409
    312410        <li>
    313411            <label>Page Meta Description</label>
  • ect-seo/trunk/readme.txt

    r1477624 r1541826  
    44Tags: Wordpress ecommerce, ecommerce, online store, sell products, shopping cart, wordpress store, wordpress shopping cart, ecommerce software, seo, meta description, title tag, search engine friendly, search engine optimization
    55Requires at least: 3
    6 Tested up to: 4.6
    7 Stable tag: 1.3
     6Tested up to: 4.6.1
     7Stable tag: 1.4
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    5555<?php echo do_shortcode('[ect_seo]')?>
    56561. Save header.php and check your title and meta description tags on your store pages.
     571. If there is no title code in header.php, enter the shortcode just before <?php wp_head(); ?>
    5758
    5859== Frequently asked questions ==
     
    8485= 1.3 =
    8586* Title and meta description tags for home page. April 23rd 2015.
     87= 1.4 =
     88* Support for header files with no title code. November 28 2016.
Note: See TracChangeset for help on using the changeset viewer.