Plugin Directory

Changeset 1965337


Ignore:
Timestamp:
10/29/2018 07:14:34 PM (7 years ago)
Author:
evoseo
Message:

62e4940 AO-1292 Update WordPress Plugin to 1.0.8
f8da6b1 AO-1304 WordPress 4.9 and Gutenberg Compatibility
7c597e1 AO-1285 Fix Undefined Variables in EVO Overview Page
0fdd6d1 AO-470 Redirect Custom Post Types

Location:
evo-seo/trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • evo-seo/trunk/admin/includes/class-evo-seo-post-metabox.php

    r1949891 r1965337  
    201201            $screen = array_merge( $built_in_post_types, $custom_post_types ),
    202202            $context = 'normal',
    203             $priority = 'high'
     203            $priority = 'high',
     204            $callback_args = array(
     205                '__block_editor_compatible_meta_box' => true,
     206            )
    204207        );
    205208    }
     
    268271                'ajaxUrl' => admin_url( 'admin-ajax.php' ),
    269272                'wpNonce' => wp_create_nonce( self::NONCE_ACTION ),
     273                'isGutenbergPage' => function_exists( 'is_gutenberg_page' ) && is_gutenberg_page(),
    270274            )
    271275        );
  • evo-seo/trunk/admin/includes/dashboard/overview/class-evo-seo-organic-traffic-handlers.php

    r1949891 r1965337  
    7070        $data_ga = $this->_get_ga_traffic_data();
    7171
    72         if ( ( 401 === $data_gsc['code'] ) && ( 401 === $data_ga['code'] ) ) {
    73             status_header( 401 );
    74             wp_send_json_error( null );
    75             wp_die();
    76         }
    77 
    78         if ( ( 403 === $data_gsc['code'] ) && ( 403 === $data_ga['code'] ) ) {
    79             status_header( 403 );
    80             wp_send_json_error( null );
    81             wp_die();
     72        // Respond with HTTP 401 or 403 if there was a problem fetching the data.
     73        if ( isset( $data_gsc['code'] ) && isset( $data_ga['code'] ) ) {
     74            if ( ( 401 === $data_gsc['code'] ) && ( 401 === $data_ga['code'] ) ) {
     75                status_header( 401 );
     76                wp_send_json_error( null );
     77                wp_die();
     78            }
     79
     80            if ( ( 403 === $data_gsc['code'] ) && ( 403 === $data_ga['code'] ) ) {
     81                status_header( 403 );
     82                wp_send_json_error( null );
     83                wp_die();
     84            }
    8285        }
    8386
     
    132135            );
    133136
    134             // Get the traffic counts for the current date from the Search Console and
    135             // Analytics data.
    136             $traffic_gsc = $data_gsc[ $date_string ];
    137             $traffic_ga = $data_ga[ $date_string ];
     137            // Get the traffic count for the current date from Search Console data.
     138            $traffic_gsc = null;
     139            if ( isset( $data_gsc[ $date_string ] ) ) {
     140                $traffic_gsc = $data_gsc[ $date_string ];
     141            } else {
     142                $traffic_gsc = 0;
     143            }
     144
     145            // Get the traffic counts for the current date from the Analytics data.
     146            $traffic_ga = null;
     147            if ( isset( $data_ga[ $date_string ] ) ) {
     148                $traffic_ga = $data_ga[ $date_string ];
     149            } else {
     150                $traffic_ga = 0;
     151            }
    138152
    139153            // Store the traffic counts in the current data point.
    140             $data_point['traffic_gsc'] = $traffic_gsc ? $traffic_gsc : 0;
    141             $data_point['traffic_ga']  = $traffic_ga ? $traffic_ga : 0;
     154            $data_point['traffic_gsc'] = $traffic_gsc;
     155            $data_point['traffic_ga']  = $traffic_ga;
    142156
    143157            // Store chart data for the current date.
     
    181195        for ( $i = 0; $i < $num_data; $i++ ) {
    182196            $date_string = $data[ $i ]['keys'][0];
    183             $count = $data[ $i ]['clicks'];
     197
     198            // Current data point.
     199            $data_i = $data[ $i ];
     200
     201            // Number of clicks.
     202            $count = 0;
     203            if ( isset( $data_i['clicks'] ) ) {
     204                $count = $data[ $i ]['clicks'];
     205            }
    184206
    185207            $new_data[ $date_string ] = $count;
     
    211233
    212234        // Return null if no data was returned.
    213         $data = $response['body']['reports'][0]['data']['rows'];
    214         if ( ! $data ) {
     235        $data = $response['body']['reports'][0]['data'];
     236        if ( isset( $data['rows'] ) ) {
     237            $data = $data['rows'];
     238        } else {
    215239            return null;
    216240        }
  • evo-seo/trunk/admin/includes/dashboard/overview/class-evo-seo-top-landing-pages-handlers.php

    r1908787 r1965337  
    5959     */
    6060    public function get_top_landing_pages() {
    61         // @codingStandardsIgnoreStart WordPress.VIP.ValidatedSanitizedInput.InputNotValidated
    62         // Extract nonce from the request.
    63         $nonce = sanitize_text_field( wp_unslash( $_POST[ self::NONCE_NAME ] ) );
    64         // @codingStandardsIgnoreEnd WordPress.VIP.ValidatedSanitizedInput.InputNotValidated
    65 
    6661        // @codingStandardsIgnoreStart WordPress.CSRF.NonceVerification.NoNonceVerification
    6762        // Check nonce, will return HTTP Status Code 403 if nonce is invalid.
  • evo-seo/trunk/admin/includes/dashboard/overview/class-evo-seo-top-performing-keywords-handlers.php

    r1908787 r1965337  
    6262     */
    6363    public function get_top_performing_keywords() {
    64         // @codingStandardsIgnoreStart WordPress.VIP.ValidatedSanitizedInput.InputNotValidated
    65         // Extract nonce from the request.
    66         $nonce = sanitize_text_field( wp_unslash( $_POST[ self::NONCE_NAME ] ) );
    67         // @codingStandardsIgnoreEnd WordPress.VIP.ValidatedSanitizedInput.InputNotValidated
    68 
    6964        // @codingStandardsIgnoreStart WordPress.CSRF.NonceVerification.NoNonceVerification
    7065        // Check nonce, will return HTTP Status Code 403 if nonce is invalid.
     
    7671
    7772        // Return response to the front-end.
    78         status_header( $response['code'] );
     73        $status_code = $response['code'];
     74        status_header( $status_code );
    7975        $status_code < 400 ? wp_send_json( $response['body'] ) : wp_send_json_error( $response );
    8076        wp_die();
  • evo-seo/trunk/admin/includes/dashboard/redirect-manager/class-evo-seo-redirect-manager-handlers.php

    r1908787 r1965337  
    12471247        }
    12481248
    1249         // Checks if URL contains Home URL.
    1250         $is_full_url = strpos( $new_url, $home_url );
    1251         // If is full URL.
    1252         if ( false !== $is_full_url ) {
    1253             return $this->_get_page_by_url( $new_url );
    1254         }
    1255 
    1256         // If there is no `/` at the beginning of $new_url, add it.
    1257         $slash_position = strpos( $new_url, '/' );
    1258         if ( $slash_position > 0 || false === $slash_position ) {
    1259             $new_url = '/' . $new_url;
    1260         }
    1261 
    1262         return $this->_get_page_by_path( $new_url );
     1249        // Try to get the post ID from the new URL.
     1250        $post_id = $this->_get_post_id_from_url( $new_url );
     1251
     1252        // If no post ID could be found, return an error.
     1253        if ( 0 === $post_id ) {
     1254            return array(
     1255                'is_valid' => false,
     1256                'id' => '',
     1257            );
     1258        }
     1259
     1260        // If a post ID was found, return relative URL.
     1261        return array(
     1262            'is_valid' => true,
     1263            'id' => $post_id,
     1264            'slug' => wp_make_link_relative( get_permalink( $post_id ) ),
     1265        );
    12631266    }
    12641267
     
    14171420        return $wpdb->prefix . 'evo_seo_redirect';
    14181421    }
     1422
     1423    /**
     1424     * Function: _get_post_id_from_url.
     1425     *
     1426     * Returns the Post ID associated with a post slug/URL.
     1427     *
     1428     * @param string $url URL or slug.
     1429     *
     1430     * @access private
     1431     * @return int Post ID.
     1432     */
     1433    private function _get_post_id_from_url( $url ) {
     1434        // Attempt to parse the given URL into components.
     1435        $parsed = wp_parse_url( $url );
     1436
     1437        // Check for a path.
     1438        if ( array_key_exists( 'path', $parsed ) ) {
     1439            // Build a full URL.
     1440            // Remove trailing slash from the site URL.
     1441            $site_url = get_site_url();
     1442
     1443            // Remove leading slash from the path.
     1444            $path = ltrim( $parsed['path'], '/' );
     1445
     1446            // Add path to the site URL.
     1447            $permalink = $site_url . '/' . $path;
     1448
     1449            // Get the post ID from the permalink.
     1450            return url_to_postid( $permalink );
     1451        }
     1452
     1453        // Return a post ID of 0 if no path was found.
     1454        return 0;
     1455    }
    14191456}
  • evo-seo/trunk/admin/js/evo-seo-post-metabox.js

    r1957099 r1965337  
    11401140      newPost = _EVO_SEO_WP.newPost;
    11411141
     1142  var isGutenbergPage = EVO_SEO_WP.isGutenbergPage === '1';
     1143
    11421144  // Exit early if not editing a Post or a Page.
    1143 
    11441145  if (!(editPost || newPost)) {
    11451146    return;
     
    12741275    var slug = event.target.value;
    12751276
     1277    // Update SERP with new Permalink URL if the Gutenberg Editor is used.
     1278    if (isGutenbergPage) {
     1279      // Permalink URL.
     1280      var _permalink = void 0;
     1281
     1282      // Click on the page title block.
     1283      var $pageTitleBlock = $('textarea#post-title-0');
     1284
     1285      // Set focus to the page title block to expose the Permalink input box.
     1286      $pageTitleBlock.trigger('focus');
     1287
     1288      // Create reference on the `Edit` permalink button.
     1289      var $btnEditPermalink = $('button.editor-post-permalink__edit');
     1290
     1291      // If there is an `Edit` permalink button, then a non-Plain permalink
     1292      // structure is set.
     1293      if ($btnEditPermalink && $btnEditPermalink.length === 1) {
     1294        // Click on the `Edit` permalink button.
     1295        $btnEditPermalink.trigger('click');
     1296
     1297        // Create a new permalink URL using the updated slug.
     1298        var $formPermalinkEditor = $('.editor-post-permalink-editor');
     1299        var prefix = $formPermalinkEditor.find('.editor-post-permalink-editor__prefix').text();
     1300        var suffix = $formPermalinkEditor.find('.editor-post-permalink-editor__suffix').text();
     1301        _permalink = '' + prefix + slug + suffix;
     1302      } else {
     1303        // If there is no `Edit` permalink button, then a Plain permalink structure
     1304        // is set. Changes to the slug will not change the permalink URL.
     1305        // Use existing permalink URL.
     1306        _permalink = $('a.editor-post-permalink__link').attr('href');
     1307      }
     1308
     1309      // Update SERP with new permalink.
     1310      $preview.all.permalink.html(_permalink);
     1311
     1312      // Set focus to the EVO `Slug` input box.
     1313      $inputSlug.trigger('focus');
     1314
     1315      return;
     1316    }
     1317
    12761318    // Hold a reference to the sample permalink DOM node.
    12771319    // There are three cases:
     
    14231465      if (title.length === 0) {
    14241466        // If the SEO title is blank, use title from the editor.
    1425         $inputTitle.val($('input[name="post_title"]').val());
     1467        var editorText = isGutenbergPage ? $('textarea#post-title-0').val() : $('input[name="post_title"]').val();
     1468        $inputTitle.val(editorText);
    14261469      } else {
    14271470        $inputTitle.val(title);
  • evo-seo/trunk/admin/views/dashboard/redirect-manager/index.php

    r1908787 r1965337  
    1515    ),
    1616);
     17
     18global $evo_seo_compatibility_check;
     19$prerequisites = array(
     20    $evo_seo_compatibility_check->is_permalink_structure_set(),
     21);
     22$warnings = $evo_seo_compatibility_check->generate_warnings( $prerequisites );
     23$has_warnings = ! empty( $warnings );
     24
    1725?>
    1826
     
    2937    <div class="page-content">
    3038        <?php
    31             include $evo_seo_redirect_manager_view_index['path']['redirect_manager'] . 'redirect-alert-banner.php';
     39            include $evo_seo_redirect_manager_view_index['path']['partials'] . 'pages-navbar.php';
    3240        ?>
    3341    </div>
    3442
    35     <div class="page-content">
    36         <?php
    37             include $evo_seo_redirect_manager_view_index['path']['partials'] . 'pages-navbar.php';
    38             include $evo_seo_redirect_manager_view_index['path']['redirect_manager'] . 'redirect-manager.php';
    39             include $evo_seo_redirect_manager_view_index['path']['redirect_manager'] . 'plain-redirects.php';
    40             include $evo_seo_redirect_manager_view_index['path']['redirect_manager'] . 'list-404s-and-redirects.php';
    41         ?>
    42     </div>
     43    <?php if ( $has_warnings ) : ?>
     44        <div class="page-content">
     45            <div class="container-warnings">
     46                <?php foreach ( $warnings as $warning ) : ?>
     47                    <?php // @codingStandardsIgnoreStart WordPress.XSS.EscapeOutput.OutputNotEscaped ?>
     48                    <?php echo $warning; ?>
     49                    <?php // @codingStandardsIgnoreEnd WordPress.XSS.EscapeOutput.OutputNotEscaped ?>
     50                <?php endforeach; ?>
     51            </div>
     52        </div>
     53
     54        <?php else : ?>
     55            <div class="page-content">
     56                <?php
     57                    include $evo_seo_redirect_manager_view_index['path']['redirect_manager'] . 'redirect-alert-banner.php';
     58                    include $evo_seo_redirect_manager_view_index['path']['redirect_manager'] . 'redirect-manager.php';
     59                    include $evo_seo_redirect_manager_view_index['path']['redirect_manager'] . 'plain-redirects.php';
     60                    include $evo_seo_redirect_manager_view_index['path']['redirect_manager'] . 'list-404s-and-redirects.php';
     61                ?>
     62            </div>
     63    <?php endif; ?>
     64
     65
    4366</div>
  • evo-seo/trunk/evo-seo.php

    r1957099 r1965337  
    1212 * Plugin URI:  https://wordpress.org/plugins/evo-seo/
    1313 * Description: EVO is a powerful, all-in-one SEO tool made by SEOs.
    14  * Version:     1.0.7
     14 * Version:     1.0.8
    1515 * Author:      evoseo
    1616 * Author URI:  https://evoplugin.com/
  • evo-seo/trunk/readme.txt

    r1957099 r1965337  
    66Loop Chain Detector, Fix 404, Robots.txt, htaccess, Cache, SERP, Search Engine Result Preview, Social, Sharing,
    77Facebook, Twitter, JSON-LD, Schema
    8 Version: 1.0.7
     8Version: 1.0.8
    99Requires at least: 4.8.0
    1010Tested up to: 4.9.8
     
    110110== Changelog ==
    111111
     112= 1.0.8 =
     113* Minimal Gutenberg Compatibility
     114* Redirect Manager Compatibility and Prerequisite Checks
     115* Redirect Manager Export and Import Support Custom Post Types
     116
    112117= 1.0.7 =
    113118* Custom Post Type Support in XML Sitemaps
     
    154159== Upgrade Notice ==
    155160
     161= 1.0.8 =
     162* None
     163
    156164= 1.0.7 =
    157165* None
Note: See TracChangeset for help on using the changeset viewer.