Plugin Directory

Changeset 2307487


Ignore:
Timestamp:
05/18/2020 09:38:00 PM (6 years ago)
Author:
alanderkin
Message:

Fix dashboard issues, signup flow and meta description saving

Location:
bruce-clay-seo/trunk
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • bruce-clay-seo/trunk/css/admin-style.css

    r2240139 r2307487  
    11/**
    2  * seotoolset: v0.7.0
     2 * seotoolset: v0.7.1
    33 */
    44pre.seotoolset {
  • bruce-clay-seo/trunk/css/admin-style.scss

    r2240139 r2307487  
    11/**
    2  * seotoolset: v0.7.0
     2 * seotoolset: v0.7.1
    33 */
    44
  • bruce-clay-seo/trunk/css/editor-style-min.css

    r2240139 r2307487  
    11/**
    2  * seotoolset: v0.7.0
     2 * seotoolset: v0.7.1
    33 */
    44
  • bruce-clay-seo/trunk/css/editor-style.css

    r2240139 r2307487  
    11/**
    2  * seotoolset: v0.7.0
     2 * seotoolset: v0.7.1
    33 */
    44
  • bruce-clay-seo/trunk/js/script.js

    r2240139 r2307487  
    11/**
    2  * seotoolset: v0.7.0
     2 * seotoolset: v0.7.1
    33 */
    44
     
    20622062            }
    20632063        );
     2064
     2065
     2066        /**
     2067         * Function to update Meta description
     2068         */
     2069        function updateMetaDescription() {
     2070            const metaTitle = $('.tab.meta-description #seotoolset_meta_title').val();
     2071            const metaDescription = $('.tab.meta-description #seotoolset_meta_description').val();
     2072            $('.tab.meta-description .seotoolset_meta_title_label').html(metaTitle);
     2073            $('.tab.meta-description .seotoolset_meta_description_label').html(metaDescription);
     2074            $.ajax({
     2075                url: seotoolset_vars.ajax_url,
     2076                type: 'post',
     2077                dataType: 'json',
     2078                data: {
     2079                    action: 'saveMetaDescription',
     2080                    seotoolset_post_id: seotoolset_vars.post_id,
     2081                    seotoolset_meta_title: metaTitle,
     2082                    seotoolset_meta_description: metaDescription
     2083                },
     2084                success: function(result) {
     2085                    let className = '';
     2086                    if (result.status === 200) {
     2087                        className = ' met';
     2088                    }
     2089                    let resultMessage = '<span class="pill"><span class="goal' + className + '">' + result.message + '</span></span>';
     2090                    $('.seo-meta-messages').html(resultMessage);
     2091                }
     2092            });
     2093        }
     2094
     2095
     2096        /**
     2097         * Selector to call updateMetaDescription() function
     2098         */
     2099        $('.tab.meta-description #seotoolset_meta_title, .tab.meta-description #seotoolset_meta_description').on('input', function() {
     2100            updateMetaDescription();
     2101        });
    20642102
    20652103
  • bruce-clay-seo/trunk/readme.txt

    r2240139 r2307487  
    55Tags: SEO, Readability, Content Analysis, Google Search Console, Google Analytics, SaaS, Competitive Analysis, Page Analysis, SERP Analysis, Search Engine Optimization, Bruce Clay
    66Requires at least: 4.5
    7 Tested up to: 5.3.2
     7Tested up to: 5.4.1
    88Requires PHP: 5.6
    9 Stable tag: v0.7.0
     9Stable tag: v0.7.1
    1010License: GNU General Public License v3
    1111License URI: https://www.gnu.org/licenses/gpl.html
     
    110110== Changelog ==
    111111
     112= 0.7.1 =
     113Release Date: May 18, 2020
     114
     115Bugfixes:
     116* Fixes functionality to save Meta Description data and have that data reflect in the page statistics.
     117* Fixes session arrays to enable saving of data between different screens.
     118* Fixes dashboard UI issues like sorting and items per page for affected dashboard views.
     119
    112120= 0.7.0 -
    113121Release Date: February 6, 2020
     
    232240
    233241= 0.7.0 =
     242Fixes bugs in saving Meta Description tags, signing up, and dashboard data. Upgrade now if you are unable to subscribe or are having trouble saving meta information for a post.
     243
     244= 0.7.0 =
    234245Fixes bugs in the UI, Yoast Compatibility, Settings and Chart components. Refactors code in order to do some more automated testing and documenting. Upgrade now if you have been seeing zeroes for data in Yoast fields, blank screens or charts or errors when saving settings.
    235246
  • bruce-clay-seo/trunk/seotoolset.php

    r2240139 r2307487  
    1717 * Plugin URI:  https://www.bruceclay.com/seo/tools/bruceclayseo/
    1818 * Description: Bruce Clay SEO gives blog writers on-page SEO guidance based on real-time competitor analysis. Analytics is integrated to show post performance, right in WordPress. Keyword tracking, reports and more powered by SEOToolSet.
    19  * Version:     0.7.0
     19 * Version:     0.7.1
    2020 * Author:      Bruce Clay, Inc.
    2121 * Author URI:  https://www.bruceclay.com/?utm_source=bc-seo&utm_medium=plugin&utm_campaign=wordpress-general
     
    4949     * Current version of the plugin.
    5050     */
    51     define('SEOTOOLSET_VERSION', '0.7.0');
     51    define('SEOTOOLSET_VERSION', '0.7.1');
    5252}
    5353
  • bruce-clay-seo/trunk/src/SEOToolSet.php

    r2240164 r2307487  
    236236       
    237237        add_action('save_post', [$this, 'apiPostsPost']);
     238        add_action('wp_ajax_saveMetaDescription', [$this, 'saveMetaDescription']);
    238239
    239240        if (is_admin()) {
     
    256257        }
    257258    }
     259
    258260
    259261    /**
     
    823825        $userId = get_current_user_id();
    824826        $expires = '30 minutes';
    825         update_user_meta($userId, "bcseo_{$key}", strtotime($expires) . ":" . $value);
     827        if (is_array($value)) {
     828            $value = json_encode($value);
     829        }
     830        update_user_meta($userId, "bcseo_{$key}", strtotime($expires) . "&" . $value);
    826831    }
    827832
     
    835840    public static function getSessionVar($key)
    836841    {
     842        $value = null;
    837843        $userId = get_current_user_id();
    838         $value = get_user_meta($userId, "bcseo_{$key}", true);
    839         preg_match(';^([0-9]+):(.*)$;', $value, $regs);
    840         return ($regs[1] < time()) ? null : $regs[2];
     844        $db_value = get_user_meta($userId, "bcseo_{$key}", true);
     845        $splitted_value = explode('&', $db_value);
     846        if (2 === count($splitted_value) && $splitted_value[0] > time()) {
     847            $value = json_decode($splitted_value[1], true);
     848            // Value is not JSON
     849            if (JSON_ERROR_NONE !== json_last_error()) {
     850                $value = $splitted_value[1];
     851            }
     852            return $value;
     853        }
     854        return null;
    841855    }
    842856
     
    10601074        //wp_register_style('jquery-ui', '//ajax.googleapis.com/ajax/libs/jqueryui/1.9/themes/base/jquery-ui.css');
    10611075        //wp_enqueue_style('jquery-ui');
     1076        $this->localizeSaveMetaDescriptionScript();
     1077    }
     1078
     1079    /**
     1080     * Function to localize script and register variables to save Meta Description
     1081     */
     1082    public function localizeSaveMetaDescriptionScript() {
     1083        global $post;
     1084        wp_localize_script(
     1085            'seotoolset-scripts',
     1086            'seotoolset_vars',
     1087            [
     1088                'ajax_url' => admin_url('admin-ajax.php'),
     1089                'post_id' => $post->ID
     1090            ]
     1091        );
     1092    }
     1093
     1094    /**
     1095     * Function to save Meta Description via AJAX
     1096     */
     1097    public function saveMetaDescription() {
     1098        global $wpdb;
     1099        $response = [];
     1100        if (!isset($_POST['seotoolset_post_id']) ||
     1101            !isset($_POST['seotoolset_meta_title']) ||
     1102            !isset($_POST['seotoolset_meta_description']) ||
     1103            $_POST['seotoolset_post_id'] == '' ||
     1104            $_POST['seotoolset_meta_title'] == '' ||
     1105            $_POST['seotoolset_meta_description'] == '') {
     1106            $response = [
     1107                'status' => 400,
     1108                'message' => 'All fields are mandatory to save Meta description data.'
     1109            ];
     1110            echo json_encode($response);
     1111            wp_die();
     1112        }
     1113        $postId = sanitize_text_field(trim($_POST['seotoolset_post_id']));
     1114        $metaTitle = sanitize_text_field(trim($_POST['seotoolset_meta_title']));
     1115        $metaDescription = sanitize_text_field(trim($_POST['seotoolset_meta_description']));
     1116        if (!is_numeric($postId)) {
     1117            $response = [
     1118                'status' => 400,
     1119                'message' => 'There was an error getting post id.'
     1120            ];
     1121            echo json_encode($response);
     1122            wp_die();
     1123        }
     1124        update_post_meta($postId, '_seotoolset_meta_title', $metaTitle);
     1125        update_post_meta($postId, '_seotoolset_meta_description', $metaDescription);
     1126        $response = [
     1127            'status' => 200,
     1128            'message' => 'Meta description data was saved successfully.'
     1129        ];
     1130        echo json_encode($response);
     1131        wp_die();
    10621132    }
    10631133
  • bruce-clay-seo/trunk/src/templates/ajax-dashboard-activity.php

    r2240164 r2307487  
    5050foreach ($arr as $color => $colorActivities) {
    5151    $count = count($colorActivities);
     52    $current_severity = false;
     53    switch( $color ) {
     54        case 'red': $current_severity = 'Error'; break;
     55        case 'yellow': $current_severity = 'Warning'; break;
     56        case 'green': $current_severity = 'Info'; break;
     57        default: $current_severity = 'Error';
     58    }
    5259    ?>
    5360                <div class="collapsible<?php echo $color == 'red' ? '' : ' closed'; ?>">
     
    5966                        </h4>
    6067                        <?php if ($count > 0) { ?>
    61                             <a class="reasons-view button" href="?page=seotoolset-activity"><?php _e('View All', SEOTOOLSET_TEXTDOMAIN); ?></a>
     68                            <a class="reasons-view button"
     69                                href="?page=seotoolset-activity<?php echo ( $current_severity ) ? '&severity=' . $current_severity : '' ?>">
     70                                <?php _e('View All', SEOTOOLSET_TEXTDOMAIN); ?>
     71                            </a>
    6272                        <?php } ?>
    6373                    </div>
    6474                    <div>
    6575                        <table class="stripes">
     76                            <?php $activities_count = 0; ?>
    6677                            <?php foreach ($colorActivities as $act) { ?>
    6778                                <?php
     79                                $activities_count++;
     80                                if( $activities_count > 10 ) {
     81                                    break;
     82                                }
    6883                                $alerts = &$act['alerts'];
    6984                                $postId = $act['post_id'];
  • bruce-clay-seo/trunk/src/templates/ajax-dashboard-content.php

    r2240164 r2307487  
    3636$args2['DateRangeStart'] = $start;
    3737$args2['DateRangeEnd'] = $end;
     38$args2['limit'] = '10';
    3839$contents = SEOToolSetAPI::apiRequest('GET', '/dashboard/content', $args2, $headers);
    3940$http_code = $contents['meta']['http_code'];
  • bruce-clay-seo/trunk/src/templates/ajax-post-meta-description.php

    r2240164 r2307487  
    8080    <div class="left one-third">
    8181        <h4><?php _e('Meta Title', SEOTOOLSET_TEXTDOMAIN); ?></h4>
    82         <input type="text" name="seotoolset_meta_title" value="<?php echo htmlspecialchars($postTitle); ?>">
     82        <input type="text" id="seotoolset_meta_title" name="seotoolset_meta_title" value="<?php echo htmlspecialchars($postTitle); ?>">
    8383
    8484        <h4><?php _e('Meta Description', SEOTOOLSET_TEXTDOMAIN); ?></h4>
    85         <textarea rows="5" name="seotoolset_meta_description"><?php echo htmlspecialchars($metaDesc); ?></textarea>
     85        <textarea rows="5" id="seotoolset_meta_description" name="seotoolset_meta_description"><?php echo htmlspecialchars($metaDesc); ?></textarea>
    8686
    8787        <div id="ajax-post-meta-keywords">
     
    9393        <h4><?php _e('Snippet Preview', SEOTOOLSET_TEXTDOMAIN); ?></h4>
    9494        <p class="snippet">
    95             <a href="@@"><?php echo $dispTitle; ?></a>
     95            <a href="@@" class="seotoolset_meta_title_label"><?php echo $dispTitle; ?></a>
    9696            <cite><?php echo $dispUrl; ?></cite><br>
    97             <span><?php echo $dispDesc; ?></span>
     97            <span class="seotoolset_meta_description_label"><?php echo $dispDesc; ?></span>
    9898        </p>
     99        <div class="seo-meta-messages"></div>
    99100    </div>
    100101
  • bruce-clay-seo/trunk/src/templates/tabs.php

    r2240164 r2307487  
    4545            try {
    4646                if (/*!is_array($activities) && */ SEOToolSet::userIsLoggedInSubscribedWithProject()) {
    47                     $activities = SEOToolSetAPI::apiRequest('GET', '/dashboard/activity');
     47                    if( isset( $_GET[ 'severity' ] ) ) {
     48                        $custom_args = [];
     49                        $custom_args[ 'severity' ] = sanitize_text_field( $_GET[ 'severity' ] );
     50                    }
     51                    $activities = SEOToolSetAPI::apiRequest( 'GET', '/dashboard/activity', $custom_args );
    4852                }
    4953                if (!is_array($activities)) {
Note: See TracChangeset for help on using the changeset viewer.