Plugin Directory

Changeset 1179063


Ignore:
Timestamp:
06/11/2015 04:02:41 PM (11 years ago)
Author:
expresscurate
Message:

new version v2.1.1 with changes:

  • New Setting: Stop Keywords. Content Feed will filter out the posts that contain these stop words.
  • New Setting: Content Alert Users. Content (Keyword Match) Alert will be sent to the specified users only.
  • New Feature: All Posts now shows the number of approved social promotion messages.
  • Miscellaneous bug fixes and improvements.
Location:
expresscurate
Files:
2 added
35 edited

Legend:

Unmodified
Added
Removed
  • expresscurate/trunk/ExpressCurate.php

    r1172885 r1179063  
    55  Plugin URI: http://www.expresscurate.com/products
    66  Description: ExpressCurate plugin is a content curation tool for WordPress. It enables you to create and publish high quality content within minutes.
    7   Version: 2.1.0
     7  Version: 2.1.1
    88  Author: ExpressCurate
    99  Author URI: http://www.expresscurate.com
  • expresscurate/trunk/ExpressCurate_Actions.php

    r1172885 r1179063  
    1616    const COLUMN_NAME = "curated";
    1717    const COLUMN_TITLE = "Curated";
     18
     19    const SOCIAL_COLUMN_NAME = "socialPosts";
     20    const SOCIAL_COLUMN_TITLE = "Social Posts";
    1821
    1922    const SMART_PUBLISH_COLUMN_NAME = "smart_publish_date";
     
    7881        add_filter('manage_edit-post_sortable_columns', array(&$this, 'curated_column_register_sortable'));
    7982
     83        add_filter('manage_edit-post_columns', array(&$this, 'social_posts_column_register'));
     84        add_action('manage_posts_custom_column', array(&$this, 'social_posts_column_display'), 10, 2);
     85        add_filter('manage_edit-post_sortable_columns', array(&$this, 'social_posts_column_register_sortable'));
     86
    8087        add_filter('request', array(&$this, 'curated_column_orderby'));
    8188        add_action('wp_enqueue_scripts', array(&$this, 'theme_styles'));
     
    95102
    96103        add_action('admin_notices', array(&$this, 'check_plugins'));
    97         add_action('save_post', array(&$this, 'save_post'),10,2);
     104        add_action('save_post', array(&$this, 'save_post'), 10, 2);
    98105        add_filter('post_updated_messages', array(&$this, 'messages'));
    99106        add_filter('mce_css', array(&$this, 'add_editor_style'));
    100107        add_filter('show_admin_bar', array(&$this, 'hide_admin_bar'));
    101         add_action('admin_init', array(&$this, 'load_source'));
     108        add_action('admin_footer', array(&$this, 'load_source'));
    102109
    103110        // Above and below content filters
     
    163170        add_action('wp_ajax_expresscurate_save_active_social_profiles', array($this->socialManager, 'saveActiveProfiles'));
    164171        add_action('wp_ajax_expresscurate_save_post_messages', array($this->socialManager, 'savePostMessages'));
     172        add_action('wp_ajax_expresscurate_save_social_publishing_status', array(&$this->socialManager, 'saveSocialPublishingStatus'));
    165173
    166174        add_action('wp_ajax_expresscurate_change_tab_event', array(&$this, 'change_tabs'));
     
    182190        add_action('transition_post_status', array(&$this, 'status_changes'), 10, 3);
    183191        add_action('update_option_permalink_structure', array(&$this, 'permalink_changes'), 10, 2);
    184         if ($_REQUEST['page'] == 'expresscurate_settings') {
     192        if (isset($_REQUEST['page']) && $_REQUEST['page'] == 'expresscurate_settings') {
    185193            $this->cronManager->schedule_events();
    186194
     
    215223        register_setting('expresscurate-group', 'expresscurate_posts_number');  // setting for post number
    216224        register_setting('expresscurate-feed-group', 'expresscurate_enable_content_alert');
     225        register_setting('expresscurate-feed-group', 'expresscurate_content_alert_users');
    217226        register_setting('expresscurate-feed-group', 'expresscurate_pull_hours_interval');
    218227        register_setting('expresscurate-feed-group', 'expresscurate_content_alert_frequency');
     228        register_setting('expresscurate-feed-group', 'expresscurate_content_stop_keywords');
    219229        register_setting('expresscurate-smartpublish-group', 'expresscurate_publish');
    220230        register_setting('expresscurate-smartpublish-group', 'expresscurate_manually_approve_smart');
     
    244254    function add_oembed_facebook()
    245255    {
    246         wp_oembed_add_provider('http://www.facebook.com/*', 'http://api.embed.ly/v1/api/oembed');
     256        wp_oembed_add_provider('http://www.facebook.com/', 'http://www.facebook.com/*');
     257        //wp_oembed_add_provider('https://www.facebook.com/*', 'https://www.facebook.com/oembedprovider');
    247258    }
    248259
     
    255266            return false;
    256267        if ($pagenow == 'post-new.php' && isset($_REQUEST['expresscurate_load_source'])) { //check for new post page
    257             ob_start();
    258268            echo '<script type="text/javascript">
    259269                   window.expresscurate_load_url =   "' . urldecode(base64_decode($_REQUEST['expresscurate_load_source'])) . '";
    260270                 </script>';
    261             ob_flush();
    262 
    263271        }
    264272    }
     
    304312        }
    305313        array_push($buttons, 'addKeyword');
    306         if (get_option('expresscurate_social_publishing', '') == "on" && strlen(get_option('expresscurate_buffer_access_token')) > 2){
     314        if (get_option('expresscurate_social_publishing', '') == "on" && strlen(get_option('expresscurate_buffer_access_token')) > 2) {
    307315            array_push($buttons, 'addSocialPost');
    308316        }
     
    377385        $tracker->track();
    378386    }
    379 
     387    /*social posts count*/
     388    // Register the column
     389    function social_posts_column_register($columns)
     390    {
     391        return array_merge($columns, array(self::SOCIAL_COLUMN_NAME => __(self::SOCIAL_COLUMN_TITLE, self::PLUGIN_FOLDER)));
     392    }
     393
     394// Display the column content
     395    public function social_posts_column_display($column_name, $post_id)
     396    {
     397        if ('socialPosts' != $column_name)
     398            return;
     399        $postsCount = get_post_meta($post_id, '_expresscurate_social_post_counter', true);
     400        $postsCount = $postsCount === '' ? '-' : $postsCount;
     401        $postsCount = '<em>' . __($postsCount, self::PLUGIN_FOLDER) . '</em>';
     402
     403        echo $postsCount;
     404    }
     405
     406// Register the column as sortable
     407    public function social_posts_column_register_sortable($columns)
     408    {
     409        $columns[self::SOCIAL_COLUMN_NAME] = self::SOCIAL_COLUMN_NAME;
     410        return $columns;
     411    }
     412
     413
     414    /**/
    380415// Register the column
    381416    function curated_column_register($columns)
     
    507542    }
    508543
    509 //    private function checkOpenTag($matches)
    510 //    {
    511 //        if (strpos($matches[0], '<') === false) {
    512 //            return $matches[0];
    513 //        } else {
    514 //            return '<strong>' . $matches[1] . '</strong>' . $this->doReplace($matches[2]);
    515 //        }
    516 //    }
    517 //
    518 //    private function doReplace($html)
    519 //    {
    520     /*        return preg_replace_callback('/(\b' . $this->word . '\b)(.*?>)/i', array(&$this, 'checkOpenTag'), $html);*/
    521 //    }
    522 //
    523 //    public function replace($html, $word)
    524 //    {
    525 //        $this->word = $word;
    526 //
    527 //        return $this->doReplace($html);
    528 //    }
    529544
    530545    public function generate_tags($post)
     
    539554            $defined_tags = explode(",", $defined_tags);
    540555        }
    541 // get the content of the post
     556        // get the content of the post
    542557        $post_content = $post->post_content;
    543558
     
    545560            $post_content = $tagsObj->removeHighlights($post_content);
    546561        }
    547         $tags = get_the_tags($post_id);
     562        $tags = get_the_tags($post->ID);
     563        $ptags = array();
    548564        if ($tags) {
    549565            foreach ($tags as $tag) {
    550566                $post_tags[$tag->term_id] = $tag->name;
     567                if (strpos($tag->name, "[ ]") > 0) {
     568                    $post_tags[$tag->term_id] = str_replace("[ ]", " ", $tag->name);
     569                    wp_update_term($tag->term_id, $tag->taxonomy, array(
     570                        'name' => $post_tags[$tag->term_id]
     571                    ));
     572                }
     573                $ptags[] = $post_tags[$tag->term_id];
    551574            }
    552575        }
     
    561584            //adding content tag to post tags if not exists
    562585            if (!in_array($content_tag_insert, $post_tags)) {
    563                 wp_set_post_tags($post->ID, strtolower($content_tag_insert), true);
    564             }
    565         }
     586                $ptags[] = $content_tag_insert;
     587            }
     588        }
     589        wp_set_post_tags($post->ID, $ptags, false);
    566590        if ($defined_tags && count($defined_tags)) {
    567591            foreach ($defined_tags as $defined_tag) {
    568592                $defined_tag_insert = trim($defined_tag);
    569                 $defined_tag_insert = preg_replace('/\s+/', '[ ]', $defined_tag_insert);
    570                 //$defined_tag_insert = preg_replace('/\s+/', '|', $defined_tag_insert);
    571593                //adding defined tag to post tags if tag exists in posttitle or post content
    572594                preg_match("/(?!<\w)(?=[^>]*(<|$))" . $defined_tag_insert . "(\W|$)/i", $post_content, $tag_in_content);
    573                 if ((isset($tag_in_content[0]) || strpos($the_post->title, $defined_tag_insert)) && !in_array($defined_tag_insert, $post_tags)) {
    574                     wp_set_post_tags($post->ID, $defined_tag_insert, true);
     595                if ((isset($tag_in_content[0]) || strpos($post->title, $defined_tag_insert)) && !in_array($defined_tag_insert, $post_tags) && !in_array($defined_tag_insert, $ptags)) {
     596                    $ptags[] = $defined_tag_insert;
    575597                }
    576598            }
    577         }
    578 
    579         $tags = get_the_tags($post_id);
    580         $count_tags = count($tags);
    581         if ($tags && count($count_tags)) {
     599            wp_set_post_tags($post->ID, $ptags, false);
     600        }
     601
     602        $tags = get_the_tags($post->ID);
     603        if ($tags && count($tags)) {
    582604            $sorted_tags = array();
    583605            foreach ($tags as $tag) {
    584                 $tag_name = preg_replace('/\s+/', '[ ]', $tag->name);
    585                 $sorted_tags[$tag_name]["count_words"] = str_word_count($tag_name);
    586                 $sorted_tags[$tag_name]["name"] = $tag_name;
    587                 $sorted_tags[$tag_name]["id"] = $tag->term_id;
     606                $sorted_tags[$tag->name]["count_words"] = str_word_count($tag->name);
     607                $sorted_tags[$tag->name]["name"] = $tag->name;
     608                $sorted_tags[$tag->name]["id"] = $tag->term_id;
    588609            }
    589610
     
    594615
    595616            foreach ($tags as $tag) {
    596                 $tag_name = preg_replace('/\s+/', '[ ]', $tag["name"]);
    597                 $post_content = $tagsObj->createTag($post_content, $tag_name, $tag["id"]);
    598             }//end tags
     617                $post_content = $tagsObj->createTag($post_content, $tag['name'], $tag["id"]);
     618            }
    599619        }
    600620        return $post_content;
     
    665685     * Save the metaboxes for this custom post type
    666686     */
    667     public function save_post($post_id,$post=null)
    668     {
    669         $post_type = $post->post_type;
     687    public function save_post($post_id, $post = null)
     688    {
     689        $post_type = (!empty($post)) ? $post->post_type : get_post_type($post_id);
    670690
    671691        if ($post_type == 'acf') {
     
    681701
    682702
     703        $post = (!empty($post)) ? $post : get_post($post_id);
    683704        // get the content of the post
    684705        if (get_option('expresscurate_smart_tagging') == "on") {
     
    687708            $post_content = $post->post_content;
    688709            $tags_obj = new ExpressCurate_Tags();
     710            $post_content = $tags_obj->removeHighlights($post_content);
    689711            $post_content = $tags_obj->removeTagLinks($post_content);
    690712        }
     
    729751
    730752            //social posts
    731           //  $expresscurate_social_post_messages = isset($_POST['expresscurate_social_post_messages']) ? $_POST['expresscurate_social_post_messages'] : '';
    732 
    733            // update_post_meta($post_id, '_expresscurate_social_post_messages', esc_attr($expresscurate_social_post_messages));
     753            //  $expresscurate_social_post_messages = isset($_POST['expresscurate_social_post_messages']) ? $_POST['expresscurate_social_post_messages'] : '';
     754
     755            // update_post_meta($post_id, '_expresscurate_social_post_messages', esc_attr($expresscurate_social_post_messages));
    734756
    735757            //post analysis notification
     
    881903                        } else if ($make_featured) {
    882904                            // create file
    883                             $file = parse_url($image,PHP_URL_PATH);
     905                            $file = parse_url($image, PHP_URL_PATH);
    884906                            $file = strtok($file, '?');
    885907
     
    912934        preg_match_all('/\sdata-curated-url\s*=\s*(["\'])((?:\\.|(?!\1).)*)\1/i', $post_content, $curated_links);
    913935
    914         $curated_links_meta = $this->get_metas($post_id,'_expresscurate_link_%','post','publish'); //get_post_meta($post_id, '_expresscurate_links');
     936        $curated_links_meta = $this->get_metas($post_id, '_expresscurate_link_%', 'post', 'publish'); //get_post_meta($post_id, '_expresscurate_links');
    915937        if (!$curated_links_meta) {
    916938            $curated_links_meta = array();
     
    10571079                add_meta_box('expresscurate_advanced_seo', ' Advanced SEO', array(&$this, 'advanced_seo'), $post_type, 'normal', 'high');
    10581080            }
    1059             if($social) {
     1081            if ($social) {
    10601082                add_meta_box('expresscurate_social_publishing', ' Social Posts', array(&$this, 'social_posts'), $post_type, 'normal', 'high');
    10611083            }
     
    10831105    <?php
    10841106    }
    1085    
     1107
    10861108    public function social_posts()
    10871109    {
     
    10901112            <?php include(sprintf("%s/templates/social_posts_widget.php", dirname(__FILE__))); ?>
    10911113        </div>
    1092         <?php
     1114    <?php
    10931115    }
    10941116
     
    14281450        wp_enqueue_script('expresscurate_utils', $pluginUrl . 'js/Utils.js', array('jquery', 'masonry', 'jquery-ui-sortable', 'wp-util'));
    14291451        wp_enqueue_script('expresscurate_dialog', $pluginUrl . 'js/Dialog.js', array('jquery', 'jquery-ui-core', 'jquery-ui-dialog'));
    1430         wp_enqueue_script('expresscurate_settings', $pluginUrl . 'js/Settings.js', array('jquery'));
     1452        wp_enqueue_script('expresscurate_settings', $pluginUrl . 'js/Settings.js', array('jquery', 'jquery-ui-autocomplete'));
    14311453        wp_enqueue_script('expresscurate_source_collection', $pluginUrl . 'js/sourceCollection.js', array('jquery'));
    14321454        wp_enqueue_script('expresscurate_social_post_widget', $pluginUrl . 'js/socialPostWidget.js', array('jquery'));
     
    15071529            add_meta_box('dashboard_widget_smartPublishing', 'Smart Publishing Overview', array(&$this, 'smart_publishing_widget'), get_current_screen(), 'side', 'high');
    15081530        }
    1509        
     1531
    15101532        if (get_option('expresscurate_social_publishing', '') == "on" && strlen(get_option('expresscurate_buffer_access_token')) > 2) {
    15111533            add_meta_box('dashboard_widget_social_publishing', 'Social Publishing Overview', array(&$this, 'social_publishing_widget'), get_current_screen(), 'side', 'high');
     
    15311553            <?php include(sprintf("%s/templates/dashboard/smart_publishing_widget.php", dirname(__FILE__))); ?>
    15321554        </div>
    1533         <?php
    1534     }
    1535    
     1555    <?php
     1556    }
     1557
    15361558    public function social_publishing_widget()
    15371559    {
     
    15401562            <?php include(sprintf("%s/templates/dashboard/social_publishing_widget.php", dirname(__FILE__))); ?>
    15411563        </div>
    1542         <?php
     1564    <?php
    15431565    }
    15441566
     
    16481670        $expresscurateWebsiteUrl = self::EXPRESSCURATE_URL;
    16491671        if (strlen(get_option('expresscurate_google_refresh_token')) < 3 && get_option('expresscurate_sitemap_submit') == 'on') {
    1650             $warnings[] = '<p>Authorise access to Google Webmaster Tools. <a class="expresscurateLink" href="' . $expresscurateWebsiteUrl . 'api/connector/google/webmasters/refreshtoken/' . $blogName . '">Authorize </a>  |  <a class="expresscurateLink" href="options-general.php?page=expresscurate_settings"> Sitemap Settings </a></p>';
     1672            $warnings[] = '<p>Authorise access to Google Search Console (aka Webmaster Tools). <a class="expresscurateLink" href="' . $expresscurateWebsiteUrl . 'api/connector/google/webmasters/refreshtoken/' . $blogName . '">Authorize </a>  |  <a class="expresscurateLink" href="options-general.php?page=expresscurate_settings"> Sitemap Settings </a></p>';
    16511673        }
    16521674
  • expresscurate/trunk/ExpressCurate_CronManager.php

    r1137344 r1179063  
    1919
    2020    public  $websiteUrlCallCronjob = null;
     21    public  $websiteUrlCallCronjobDeleteAfter = null;
    2122
    2223    public function __construct() {
    2324        $this->websiteUrlCallCronjob ='0 * * * *  wget  '.get_site_url().' > /dev/null 2>&1';
     25        $this->websiteUrlCallCronjobDeleteAfter ='0 * * * * wget --delete-after '.get_site_url().' > /dev/null 2>&1';
    2426    }
    2527
     
    4143
    4244            $execExists = function_exists('exec');
    43             $cronjobExists = $this->check_if_exist($this->websiteUrlCallCronjob);
    4445
    45             if ($execExists && !$cronjobExists) {
    46                 ExpressCurate_Util::exec('crontab -l' ,$output);
     46            if($execExists) {
     47                ExpressCurate_Util::exec('crontab -l', $output);
    4748                $output = implode(PHP_EOL, $output);
    48                 $output = $output . PHP_EOL . $this->websiteUrlCallCronjob . PHP_EOL;
    49                
    50                 $tempFile =  ExpressCurate_Util::tmpname('cron');
     49
     50                $cronjobExists = $this->check_if_exist($this->websiteUrlCallCronjob, $output) || $this->check_if_exist($this->websiteUrlCallCronjobDeleteAfter, $output);
     51
     52                if ($cronjobExists) {
     53                    $this->websiteUrlCallCronjob . PHP_EOL;
     54                    $this->websiteUrlCallCronjobDeleteAfter . PHP_EOL;
     55                }
     56
     57                $output = $output . PHP_EOL . $this->websiteUrlCallCronjobDeleteAfter . PHP_EOL;
     58
     59                $tempFile = ExpressCurate_Util::tmpname('cron');
    5160                file_put_contents($tempFile, $output);
    5261                ExpressCurate_Util::exec('crontab ' . $tempFile, $output);
     
    8392        wp_clear_scheduled_hook('expresscurate_sitemap_push');
    8493
    85         if($this->check_if_exist($this->websiteUrlCallCronjob)) {
     94        $execExists = function_exists('exec');
     95
     96        if($execExists) {
    8697            ExpressCurate_Util::exec('crontab -l', $output);
     98            $cronjobExists = $this->check_if_exist($this->websiteUrlCallCronjob, $output) || $this->check_if_exist($this->websiteUrlCallCronjobDeleteAfter, $output);
    8799            $output = implode(PHP_EOL, $output);
    88             $output = str_replace($this->websiteUrlCallCronjob, "", $output) . PHP_EOL;
    89            
    90             $tempFile =  ExpressCurate_Util::tmpname('cron');
     100
     101            if ($cronjobExists) {
     102                $output = str_replace($this->websiteUrlCallCronjob, "", $output) . PHP_EOL;
     103                $output = str_replace($this->websiteUrlCallCronjobDeleteAfter, "", $output) . PHP_EOL;
     104            }
     105
     106            $tempFile = ExpressCurate_Util::tmpname('cron');
    91107            file_put_contents($tempFile, $output);
    92108            ExpressCurate_Util::exec('crontab ' . $tempFile);
     
    108124     * Check if cron job exists
    109125     */
    110     public function check_if_exist($command) {
    111         ExpressCurate_Util::exec('crontab -l', $crontab);
     126    public function check_if_exist($command, $crontab) {
    112127        if(isset($crontab) && is_array($crontab)){
    113128            $crontab = array_flip($crontab);
  • expresscurate/trunk/ExpressCurate_Email.php

    r1137344 r1179063  
    1616    private $customerEmail = null;
    1717
     18    public function hasContentAlertRecipients()
     19    {
     20        $alertUsers = trim(get_option('expresscurate_content_alert_users', ''));
     21        return strlen($alertUsers) > 0;
     22    }
     23
    1824    public function sendContentAlertEmail($emailData)
    1925    {
     26        // render the email
    2027        ob_start();
    2128        include(sprintf("%s/templates/email/contentAlert.php", dirname(__FILE__)));
    2229        $email = ob_get_clean();
    2330
     31        // define headers
     32        $headers = 'Content-type: text/html; charset=utf-8' . "\r\n";
     33       
     34        // get recipients
    2435        $wpUsers = get_users();
    25         $headers = 'Content-type: text/html; charset=utf-8' . "\r\n";
     36        $alertUsers = split(',', trim(get_option('expresscurate_content_alert_users', '')));
     37        // TODO optimize to load only the users we need
    2638        foreach ($wpUsers as $user) {
    2739            // don't sent alerts to subscribers
    28             if(in_array('subscriber', $user->roles)) {
     40            if(in_array('subscriber', $user->roles) || !in_array($user->user_login, $alertUsers)) {
    2941                continue;
    3042            }
    3143            @wp_mail($user->user_email, 'ExpressCurate Content Alert', $email, $headers);
    3244        }
     45        // set the last alert time
    3346        update_option('expresscurate_content_alert_lastDate', date('Y-m-d H:i:s'));
    34 
    3547    }
    3648
  • expresscurate/trunk/ExpressCurate_FeedManager.php

    r1165036 r1179063  
    6464                    if (filter_var($rssUrl, FILTER_VALIDATE_URL)) {
    6565                        $result['status'] = 'success';
    66                        
     66
    6767                        // retrieve the feed title
    6868                        $feedMeta = $this->getFeedMeta($rssUrl);
    6969                        $link = $feedMeta['link'];
    7070                        $link = empty($link) ? $rssUrl : $link;
    71                        
     71
    7272                        // get the number of posts that are curated from this feed
    7373                        $metas = $wpdb->get_results(
     
    8181                        $curated_links_rss[$rssUrl]['post_count'] = $result['post_count'] = count($metas);
    8282                        $curated_links_rss[$rssUrl]['feed_title'] = $result['feed_title'] = $feedMeta['title'];
    83                        
     83
    8484                        // save
    8585                        update_option('expresscurate_links_rss', json_encode($curated_links_rss));
     
    9696        die;
    9797    }
    98    
     98
    9999    private function getFeedMeta($feedURL) {
    100100        $loadURL = "http://ajax.googleapis.com/ajax/services/feed/load?v=1.0&q=" . urlencode($feedURL);
     
    102102        $res = $htmlparser->download();
    103103        $result = json_decode($res, true);
    104        
     104
    105105        if(isset($result['responseData']) && isset($result['responseData']['feed'])) {
    106106            $meta = array();
     
    159159        if ($curated_links_rss) {
    160160            $curated_links_rss = json_decode($curated_links_rss, true);
    161            
     161
    162162            $links = array();
    163163            foreach($curated_links_rss as $link => $data) {
     
    197197                            $url = parse_url($meta_values[$key][0]);
    198198                            $host = $url['host'];
    199                            
     199
    200200                            // get only the main domain
    201201                            preg_match('/([a-z0-9\-_]{1,63})\.([a-z]{2,6})$/i', $host, $regs);
    202202                            $link = $regs[1] . '.' . $regs[2];
    203                            
     203
    204204                            // filter
    205205                            if(empty($link) || $link == '.') {
    206206                                continue;
    207207                            }
    208                            
     208
    209209                            // add
    210210                            $curated_links[$i]['host'] = $host;
     
    218218        }
    219219        wp_reset_postdata();
    220        
     220
    221221        $rssLinks = array();
    222        
     222
    223223        if(ExpressCurate_HtmlParser::supportsDownload()) {
    224224            foreach ($curated_links as $key => $top_link) {
    225225                $websiteHost = $top_link['host'];
    226226                $website = $top_link['link'];
    227                
     227
    228228                if(isset($rssLinks[$websiteHost])) {
    229229                    $rssUrl = $rssLinks[$websiteHost];
     
    232232                    $rssLinks[$websiteHost] = $rssUrl;
    233233                }
    234                
     234
    235235                if ($rssUrl && isset($curated_links_rss[$rssUrl])) {
    236236                    $feed_status = 'rssStatusYes';
     
    242242                    }
    243243                }
    244                
     244
    245245                $top_sources_rss['links'][$website] = array(
    246246                    'post_ids' => array($top_link['post_id']),
     
    276276    {
    277277        global $wpdb;
    278        
     278
    279279        $curated_links_rss = get_option('expresscurate_links_rss', '');
    280280        if ($curated_links_rss) {
    281281            $curated_links_rss = json_decode($curated_links_rss, true);
    282            
     282
    283283            $save = false;
    284284            foreach($curated_links_rss as $rss => $data) {
     
    286286                    continue;
    287287                }
    288                
     288
    289289                // correct the url and get the meta data
    290290                $rssUrl = $this->getRssUrl($rss);
     
    292292                $link = $feedMeta['link'];
    293293                $link = empty($link) ? $rssUrl : $link;
    294                
     294
    295295                $data = array();
    296296                $data['feed_title'] = $feedMeta['title'];
    297297                $data['feed_url'] = $rssUrl;
    298298                $data['link'] = $link;
    299                
     299
    300300                // remove the old row and add the new one
    301301                unset($curated_links_rss[$rss]);
    302302                $curated_links_rss[$link] = $data;
    303                
     303
    304304                // make sure to save in the end
    305305                $save = true;
    306306            }
    307            
     307
    308308            // update the post count
    309309            foreach($curated_links_rss as $link => $data) {
     
    313313                             FROM $wpdb->postmeta
    314314                             WHERE meta_key LIKE  '%_expresscurate_link_%' AND meta_value LIKE '%" . $link . "%' GROUP BY post_id");
    315                
     315
    316316                $curated_links_rss[$link]['post_count'] = count($posts);
    317317            }
    318            
     318
    319319            // save
    320320            update_option('expresscurate_links_rss', json_encode($curated_links_rss));
     
    322322            $curated_links_rss = array();
    323323        }
    324        
     324
    325325        unset($curated_links_rss['']);
    326326        return $curated_links_rss;
     
    370370        return false;
    371371    }
    372    
    373    
     372
     373
    374374
    375375    public function get_feed_content()
     
    387387        $data = $_REQUEST;
    388388        $pull_feed_interval = (get_option('expresscurate_pull_hours_interval')) ? get_option('expresscurate_pull_hours_interval') : 1;
    389         $date = ($data["date"]) ? urldecode($data["date"]) : date('Y-m-d H:i:s', strtotime("-" . $pull_feed_interval . " hour"));
     389            $date = ($data["date"]) ? urldecode($data["date"]) : date('Y-m-d H:i:s', strtotime("-" . $pull_feed_interval . " hour"));
    390390        $curated_links_rss = get_option('expresscurate_links_rss', '');
    391391        if ($curated_links_rss) {
     
    403403                }
    404404            }
    405            
     405
    406406            // go over the feeds and try to pull
    407407            $curated_links_rss = json_decode($curated_links_rss, true);
     
    409409                foreach ($curated_links_rss as $url => $feed_url) {
    410410                    // pull content
    411                     $lookup_url = "http://ajax.googleapis.com/ajax/services/feed/load?v=1.0&q=" . urlencode($feed_url['feed_url']);
     411                    $lookup_url = "http://ajax.googleapis.com/ajax/services/feed/load?v=1.0&scoring=h&q=" . urlencode($feed_url['feed_url']);
    412412                    $htmlparser = new ExpressCurate_HtmlParser($lookup_url);
    413413                    $res = $htmlparser->download();
     
    421421            if(!empty($feed_array)) {
    422422                @uasort($feed_array, array($this, "feedSortByDate"));
    423                
     423
    424424                // check if the feed is full or not
    425425                if(count($feed_array) > self::CONTENT_FEED_MAX_SIZE) {
     
    430430                }
    431431            }
    432            
     432
    433433            // save the latest feed
    434434            $feed_content = json_encode(array('date' => date('Y-m-d H:i:s'), 'content' => $feed_array));
     
    437437        }
    438438    }
    439    
     439
    440440    private function collect_feed($result, $deleted_urls, &$feed_array, $type = 'feed', $date = false)
    441441    {
     
    448448            }
    449449        }
     450       
     451        $blockWords = split(',', trim(get_option('expresscurate_content_stop_keywords', '')));
     452        $blockWords = empty($blockWords) ? false : $blockWords;
     453       
    450454        foreach ($feeds as $story) {
    451455            // get the post url
     
    454458                continue;
    455459            }
    456            
     460
    457461            // parse the post url
    458462            $parsedLink = parse_url($link);
    459            
     463
    460464            // google alerts support
    461465            // check for google redirect urls and pick up the original post link
    462466            $protocol = $parsedLink['scheme'];
    463             if (strpos($protocol . "://www.google.com/url", $url) == 0) {
     467            if (strpos($protocol . "://www.google.com/url", $link) == 0) {
    464468                $query = $parsedLink['query'];
    465469                $url_query = explode("&", $query);
     
    473477                }
    474478            }
    475            
     479
    476480            // check if this link is already in the feed
    477481            if(isset($feed_array[$link])) {
    478482                continue;
    479483            }
    480            
     484
    481485                $domain = parse_url($link);
    482486                if (preg_match('/(?P<subdomain>.<domain>[a-z0-9][a-z0-9\-]{1,63}\.[a-z\.]{2,6})$/i', $parsedLink['host'], $regs)) {
     
    485489                    $domain = $domain['host'];
    486490                }
    487                
     491
    488492                // download and analyze
    489493                $html_parser = new ExpressCurate_HtmlParser($link);
     
    493497                    continue;
    494498                }
     499
     500                if($blockWords) {
     501                    $blocked = $html_parser->contains($blockWords);
     502                    if($blocked) {
     503                        continue;
     504                    }
     505                }
     506               
    495507               
    496508                $keywords = $html_parser->analyzeKeywords();
    497509                $media = $html_parser->containsMedia();
    498                
     510
    499511                $publishDate = isset($story['publishedDate']) ? $story['publishedDate'] : $story['date'];
    500512                $expressCurateDate = new ExpressCurate_Date();
    501513                $publishDate = $expressCurateDate->dateWithTimeUtc(strtotime($publishDate));
    502                
     514
    503515                $story_array = array(
    504516                    'title' => str_replace("&quot;","'",$story['title']),
     
    532544        // get feed data
    533545        $feeds = json_decode($this->get_feed_content(), true);
    534        
     546
    535547        // reschedule the cronjob
    536548        //if(!empty($feeds['content'])) {
     
    540552        $feeds["minutes_to_next_pull"] = human_time_diff(wp_next_scheduled('expresscurate_pull_feeds'), time());
    541553        //}
    542        
     554
    543555        // return
    544556        echo json_encode($feeds);
     
    551563        die;
    552564    }
    553    
     565
    554566    public function filter_feeds_by_date() {
    555567        $data = $_REQUEST;
     
    570582
    571583        if (get_option('expresscurate_enable_content_alert') == 'on') {
     584            $expressCurateEmail = new ExpressCurate_Email();
     585           
     586            $alertAddresses = trim(get_option('expresscurate_content_alert_users', ''));
     587            if(!$expressCurateEmail->hasContentAlertRecipients()) {
     588                return;
     589            }
     590       
    572591            $feed_content = json_decode(get_option('expresscurate_feed_content', ''), true);
    573592
     
    585604                }
    586605                if (!empty($emailStories)) {
    587                     $expressCurateEmail = new ExpressCurate_Email();
    588606                    $expressCurateEmail->sendContentAlertEmail($emailStories);
    589 
    590                 }
    591 
    592             }
    593         }
    594 
     607                }
     608            }
     609        }
    595610    }
    596611
     
    655670                    $current_user = wp_get_current_user();
    656671                    $item['user'] = $current_user->display_name;
    657                    
     672
    658673                    $this->collectBookmark($bookmarks, $item);
    659                    
     674
    660675                    $result[$bookmarkURL]['status'] = 'success';
    661676                }
    662677            }
    663            
     678
    664679            // save the updated bookmarks
    665680            update_option('expresscurate_bookmarks', json_encode($bookmarks));
     
    683698                // get the url
    684699                $bookmarkURL = $data['url'];
    685                
     700
    686701                // clean-up the provided url
    687702                // parse the post url
    688703                $parsedLink = parse_url($bookmarkURL);
    689            
     704
    690705                // google alerts supportbookmarkURL   // check for google redirect urls and pick up the original post link
    691706                $protocol = $parsedLink['scheme'];
     
    701716                    }
    702717                }
    703                
     718
    704719                // read the existing bookmarks
    705720                $bookmarks = get_option('expresscurate_bookmarks', '');
     
    709724                    $bookmarks = array();
    710725                }
    711                
     726
    712727                // check if the provided url is already bookmarked
    713728                if (isset($bookmarks[$bookmarkURL])) {
     
    716731                        // save the new comment
    717732                        $bookmarks[$bookmarkURL]['comment'] = $data['comment'];
    718                        
     733
    719734                        // construct the result
    720735                        $result['status'] = 'success';
    721736                        $result['result'] = $bookmarkURL;
    722                        
     737
    723738                        // save the updated bookmarks
    724739                        update_option('expresscurate_bookmarks', json_encode($bookmarks));
     
    734749                    $contentManager = new ExpressCurate_ContentManager();
    735750                    $article = $contentManager->getArticle($bookmarkURL, false);
    736                    
     751
    737752                    // check if the article is loaded successfully
    738753                    if (isset($article['status']) && $article['status'] == 'success') {
    739754                        // get the comment
    740755                        $comment = isset($data['comment']) ? $data['comment'] : '';
    741                        
     756
    742757                        // set the type and author
    743758                        $article['type'] = isset($data['type']) ? $data['type'] : 'user';
    744759                        $current_user = wp_get_current_user();
    745760                        $article['result']['user'] = $current_user->display_name;
    746                        
     761
    747762                        // ...
    748763                        $this->collectBookmark($bookmarks, $article, $bookmarkURL, $comment);
    749                        
     764
    750765                        // construct the result
    751766                        $result['status'] = 'success';
    752767                        $result['result'] = $bookmarks[$bookmarkURL];
    753768                        $result['result']['curateLink'] = base64_encode(urlencode($bookmarkURL));
    754                        
     769
    755770                        // save the updated bookmarks
    756771                        update_option('expresscurate_bookmarks', json_encode($bookmarks));
     
    773788        die;
    774789    }
    775    
     790
    776791    private function collectBookmark(&$bookmarks, $item, $url = null, $comment = '') {
    777792        if ($url) {
     
    790805                $bookmark['comment'] = $comment;
    791806                $bookmark['curated'] = 0;
    792                
     807
    793808                $bookmark['type'] = isset($item['result']['type']) ? $item['type'] : 'user';
    794                
     809
    795810                // add the bookmark to the list
    796811                $bookmarks[$url] = $bookmark;
     
    803818                $item['comment'] = $comment;
    804819                $item['bookmark_date'] = date('Y-m-d H:i:s');
    805                
     820
    806821                $bookmarks[$item['link']] = $item;
    807822            }
     
    884899    {
    885900        $needle = !empty($_GET['searchKeyword']) ? $_GET['searchKeyword'] : ' ';
    886         $resulArray = array();
     901        $resultArray = array();
    887902        $hayStack = array();
    888903
     
    901916                $feeds = array();
    902917            }
    903             $hayStack = array_merge($bookmarks, $feeds);
    904         }
    905 
    906         foreach ($hayStack as $content) {
    907             if (mb_stripos($content['title'], $needle) != false) {
    908                 $resulArray[] = $content;
    909             }
    910         }
    911 
    912         echo json_encode($resulArray);
     918            if(!empty($bookmarks)){
     919                $hayStack = array_merge($bookmarks, $feeds);
     920            }
     921        }
     922
     923        if(!empty($hayStack)){
     924            foreach ($hayStack as $content) {
     925                if (mb_stripos($content['title'], $needle) != false) {
     926                    $resultArray[] = $content;
     927                }
     928            }
     929        }
     930
     931        echo json_encode($resultArray);
    913932        die;
    914933    }
  • expresscurate/trunk/ExpressCurate_GoogleClient.php

    r1140784 r1179063  
    2222        if($accessToken == null) {
    2323            // no access token, break!
    24             $response = array('status'=> 1,'message' => 'ExpressCurate shall be authorized to access to Google Webmaster Tools.');
     24            $response = array('status'=> 1,'message' => 'ExpressCurate shall be authorized to access to Google Search Console (aka Webmaster Tools).');
    2525            return $response;
    2626        }
     
    4848        } else if($httpCode == 401) {
    4949            $decodedResponse = json_decode($response, true);
    50             $response = array('status'=> 1,'message' => 'ExpressCurate shall be authorized to access to Google Webmaster Tools.');
     50            $response = array('status'=> 1,'message' => 'ExpressCurate shall be authorized to access to Google Search Console (aka Webmaster Tools).');
    5151        } else {
    5252            $decodedResponse = json_decode($response, true);
    53             $response = array('status'=> 2,'message' => isset($decodedResponse['error']) ? $decodedResponse['error'] : 'Something went wrong. Please, make sure you have authorized ExpressCurate to access to Google Webmaster Tools.');
     53            $response = array('status'=> 2,'message' => isset($decodedResponse['error']) ? $decodedResponse['error'] : 'Something went wrong. Please, make sure you have authorized ExpressCurate to access to Google Search Console (aka Webmaster Tools).');
    5454        }
    5555        return $response;
  • expresscurate/trunk/ExpressCurate_HtmlParser.php

    r1165036 r1179063  
    4747    }
    4848
     49    public static function isNotSafeMode()
     50    {
     51        $safeMode = ini_get('safe_mode');
     52        if($safeMode && version_compare(PHP_VERSION, '5.4.0') < 0) {
     53            return false;
     54        } else {
     55            return true;
     56        }
     57    }
     58
    4959    public static function supportsDownload()
    5060    {
     
    105115            return true;
    106116        }
    107         if (is_array($this->dataHTTPStatus) && ($this->dataHTTPStatus[0] == "HTTP/1.1 301 Moved Permantenly" || strpos($this->dataHTTPStatus[0], '301')) || ($this->dataHTTPStatus[0] == "HTTP/1.1 302 Found" || strpos($this->dataHTTPStatus[0], '302')) || ($this->dataHTTPStatus[0] == "HTTP/1.1 303 See Other" || strpos($this->dataHTTPStatus[0], '303')) || ($this->dataHTTPStatus[0] == "HTTP/1.1 307 Temporary Redirect" || strpos($this->dataHTTPStatus[0], '307')) || ($this->dataHTTPStatus[0] == "HTTP/1.1 308 Permanent Redirect" || strpos($this->dataHTTPStatus[0], '308'))){
     117        if (is_array($this->dataHTTPStatus) && ($this->dataHTTPStatus[0] == "HTTP/1.1 301 Moved Permantenly" || strpos($this->dataHTTPStatus[0], '301')) || ($this->dataHTTPStatus[0] == "HTTP/1.1 302 Found" || strpos($this->dataHTTPStatus[0], '302')) || ($this->dataHTTPStatus[0] == "HTTP/1.1 303 See Other" || strpos($this->dataHTTPStatus[0], '303')) || ($this->dataHTTPStatus[0] == "HTTP/1.1 307 Temporary Redirect" || strpos($this->dataHTTPStatus[0], '307')) || ($this->dataHTTPStatus[0] == "HTTP/1.1 308 Permanent Redirect" || strpos($this->dataHTTPStatus[0], '308'))) {
    108118            return true;
    109119        }
     
    210220
    211221
    212     public function getRealURL(){
    213         if(self::supportsAsynch()){
     222    public function getRealURL()
     223    {
     224        if (self::supportsAsynch()) {
    214225            $ch = curl_init();
    215226            curl_setopt($ch, CURLOPT_URL, $this->url);
     
    218229            curl_setopt($ch, CURLOPT_NOBODY, 1);
    219230            curl_exec($ch);
    220             $this->url = curl_getinfo($ch,CURLINFO_EFFECTIVE_URL);
     231            $this->url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
    221232            curl_close($ch);
    222         }else{
     233        } else {
    223234            $headers = get_headers($this->url);
    224             foreach($headers as $header) {
     235            foreach ($headers as $header) {
    225236                if (strpos($header, "Location:") === 0) {
    226237                    $this->url = trim(substr($header, 9));
     
    237248        }
    238249        set_time_limit(0);
    239       if (self::supportsAsynch()) {
    240           // setup the single curl
    241           $ch = $this->createCURL($this->url);
    242           $content = curl_exec($ch);
    243           //$this->dataHTTPStatus = curl_getinfo($this->asynchHandle, CURLINFO_HTTP_CODE);
    244           $this->dataHTTPStatus = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    245           $contentType = curl_getinfo($ch, CURLINFO_CONTENT_TYPE);
    246           curl_close($ch);
    247       } else {
    248           $header = '';
    249           if ($this->referer) {
    250               $header .= 'Referer: ' . $this->referer . '\r\n';
    251           }
    252           if (!$this->raw) {
    253               $header .= 'Accept: application/xhtml+xml, application/xml, text/html\r\n';
    254               $header .= 'Accept-Charset: UTF-8';
    255           }
    256           $options = array('http' => array(
    257             'user_agent' => ExpressCurate_Actions::USER_AGENT,
    258             'follow_location' => 1,
    259             'max_redirects' => 5,
    260             'request_fulluri ' => TRUE,
    261             'timeout' => self::$REQUEST_TIMEOUT,
    262             'header' => $header));
    263         if (strpos($this->url, 'https://') === 0) {
    264             $options['ssl'] = array('verify_peer' => false, 'verify_peer_name' => false);
    265         }
    266         $context = stream_context_create($options);
    267         $content = @file_get_contents($this->url, false, $context);
    268         //var_dump($content);
    269         // $http_response_header gets loaded once file get contents is called, php native stuff
    270         $this->dataHTTPStatus = $http_response_header;
    271 
    272         // try to resolve the content encoding if text/html content
    273         if (!$this->raw) {
    274             if (!empty($http_response_header)) {
    275                 foreach ($http_response_header as $header) {
    276                     if (substr(strtolower($header), 0, 13) == "content-type:") {
    277                         $contentTypeData = explode(";", $header);
    278                         if (count($contentTypeData) == 2) {
    279                             list( , $contentType) = $contentTypeData;
     250        if (self::supportsAsynch()&& self::isNotSafeMode() && strlen(ini_get('open_basedir'))==0) {
     251
     252            // setup the single curl
     253            $ch = $this->createCURL($this->url);
     254            $content = curl_exec($ch);
     255            //$this->dataHTTPStatus = curl_getinfo($this->asynchHandle, CURLINFO_HTTP_CODE);
     256            $this->dataHTTPStatus = curl_getinfo($ch, CURLINFO_HTTP_CODE);
     257            $contentType = curl_getinfo($ch, CURLINFO_CONTENT_TYPE);
     258            curl_close($ch);
     259        } else {
     260            $header = '';
     261            if ($this->referer) {
     262                $header .= 'Referer: ' . $this->referer . '\r\n';
     263            }
     264            if (!$this->raw) {
     265                $header .= 'Accept: application/xhtml+xml, application/xml, text/html\r\n';
     266                $header .= 'Accept-Charset: UTF-8';
     267            }
     268            $options = array('http' => array(
     269                'user_agent' => ExpressCurate_Actions::USER_AGENT,
     270                'follow_location' => 1,
     271                'max_redirects' => 5,
     272                'request_fulluri ' => TRUE,
     273                'timeout' => self::$REQUEST_TIMEOUT,
     274                'header' => $header));
     275            if (strpos($this->url, 'https://') === 0) {
     276                $options['ssl'] = array('verify_peer' => false, 'verify_peer_name' => false);
     277            }
     278            $context = stream_context_create($options);
     279            $content = @file_get_contents($this->url, false, $context);
     280
     281            // $http_response_header gets loaded once file get contents is called, php native stuff
     282            $this->dataHTTPStatus = $http_response_header;
     283
     284            // try to resolve the content encoding if text/html content
     285            if (!$this->raw) {
     286                // try to resolve the content type from headers
     287                $encoding = false;
     288                if (!empty($http_response_header)) {
     289                    foreach ($http_response_header as $header) {
     290                        if (substr(strtolower($header), 0, 13) == "content-type:") {
     291                            // get content type
     292                            $contentTypeData = explode(";", $header);
     293                            if (count($contentTypeData) == 2) {
     294                                list(, $contentType) = $contentTypeData;
     295                            }
     296
     297                            // resolve encoding
     298                            if ($contentType) {
     299                                list(, $encoding) = explode("=", $contentType);
     300                                $encoding = strtoupper(trim($encoding));
     301
     302                                $supportedEncoding = array_search($encoding, mb_list_encodings()) !== false;
     303
     304                                if (!$supportedEncoding) {
     305                                    $encoding = false;
     306                                }
     307                            }
    280308                        }
    281309                    }
     
    283311            }
    284312        }
    285       }
    286313        // make sure if there is a response at all
    287314        if ($this->isHTTPStatusOK() === false) {
     
    293320        // there is data with OK code, process if required
    294321        if (!$this->raw) {
     322            // cleanup the content
    295323            $content = self::sanitizeContent($content);
    296324
    297             if ($contentType) {
    298                 list( , $encoding) = explode("=", $contentType);
    299                 $encoding = strtoupper(trim($encoding));
    300 
    301                 $supportedEncoding = array_search($encoding, mb_list_encodings()) !== false;
    302 
    303                 if (!$supportedEncoding) {
    304                     $encoding = mb_detect_encoding($content);
    305                 }
    306 
     325            // check if encoding is found
     326            if($encoding == false) {
     327                preg_match('/<meta.*?http-equiv\s*=\s*("|\')Content-Type("|\')\s*content\s*=\s*("|\')([a-z1-9\/\-\+\;\= ]+)("|\')/i', $content, $matches);
     328                $contentType = count($matches) > 0 ? trim($matches[4]) : false;
     329
     330                // resolve encoding
     331                if ($contentType) {
     332                    list(, $encoding) = explode("=", $contentType);
     333                    $encoding = strtoupper(trim($encoding));
     334
     335                    $supportedEncoding = array_search($encoding, mb_list_encodings()) !== false;
     336
     337                    if (!$supportedEncoding) {
     338                        $encoding = false;
     339                    }
     340                }
     341            }
     342
     343            // if no encoding was resolved so far, try to detect
     344            if($encoding == false) {
     345                $encoding = mb_detect_encoding($content);
     346            }
     347
     348            // fix up the encoding
     349            if ($encoding !== false) {
    307350                $content = mb_convert_encoding($content, 'UTF-8', $encoding);
    308351                $content = mb_convert_encoding($content, 'HTML-ENTITIES', 'UTF-8');
    309 
    310352            }
    311353        }
     
    389431    }
    390432
    391     private function parseArticles(){
     433    private function parseArticles()
     434    {
    392435        if ($this->articles == null) {
    393436            // TODO check the xpath object problem, the final article shall support the same query method
    394437
    395438            $article = $this->xpath->query('//article');
    396             if ($article->length==0) {
     439            if ($article->length == 0) {
    397440                //$article = $this->xpath->query("//*[contains(concat(' ', normalize-space(@class), ' '), 'hentry')]");
    398441                $article = $this->xpath->query('//div[contains(concat("\s+", normalize-space(@class), "\s+"), " hentry ")]');
    399442            }
    400             if ($article->length==0) {
     443            if ($article->length == 0) {
    401444                $article = $this->xpath->query("//*[contains(@itemtype, 'http://schema.org/Article')]");
    402445            }
    403             if ($article->length==0) {
     446            if ($article->length == 0) {
    404447                $article = $this->xpath->query("//*[contains(@itemtype, 'http://schema.org/TechArticle')]");
    405448            }
    406449
    407             if ($article->length==0) {
     450            if ($article->length == 0) {
    408451                $article = $this->xpath->query("//*[contains(@itemtype, 'http://schema.org/ScholarlyArticle')]");
    409452            }
    410453
    411             if ($article->length==0) {
     454            if ($article->length == 0) {
    412455                $article = $this->xpath->query('//body');
    413456            }
     
    513556    }
    514557
     558    public function contains($words)
     559    {
     560        $this->download();
     561
     562        // TODO optimize to "cache" the regexp generation
     563        $escaped = array();
     564        foreach ($words as $word) {
     565            $escaped[] = preg_quote($word);
     566        }
     567        $escapedExp = implode('|', $escaped);
     568
     569        $matches = array();
     570        preg_match('/' . $escapedExp . '/i', $this->data, $matches);
     571        return !empty($matches);
     572    }
     573
    515574    public function getContents()
    516575    {
     
    531590        }
    532591    }
    533    
     592
    534593    public function getCloneContents()
    535594    {
     
    566625        preg_match('/<meta.*?name=("|\')keywords("|\').*?content=("|\')(.*?)("|\')/i', $this->data, $matches);
    567626        if (count($matches) > 4) {
    568             if(strpos(trim($matches[4]),',')){
     627            if (strpos(trim($matches[4]), ',')) {
    569628                return array_filter(explode(",", trim($matches[4])));
    570             }
    571             else{
     629            } else {
    572630                return array_filter(explode(" ", trim($matches[4])));
    573631            }
     
    577635        preg_match('/<meta.*?content=("|\')(.*?)("|\').*?name=("|\')keywords("|\')/i', $this->data, $matches);
    578636        if (count($matches) > 2) {
    579             if(strpos(trim($matches[2]),',')){
     637            if (strpos(trim($matches[2]), ',')) {
    580638                return array_filter(explode(",", trim($matches[2])));
    581             }
    582             else{
     639            } else {
    583640                return array_filter(explode(" ", trim($matches[2])));
    584641            }
     
    686743            $result_paragraphs[$i]['tag'] = 'blockquote';
    687744            $i++;
    688            
     745
    689746            $blockquote->parentNode->removeChild($blockquote);
    690747        }
    691        
     748
    692749        // get paragraphs
    693750        $paragraphTag = $this->xpath->query(".//p", $this->article);
     
    696753            $result_paragraphs[$i]['tag'] = 'p';
    697754            $i++;
    698            
     755
    699756            $paragraph->parentNode->removeChild($paragraph);
    700757        }
     
    768825    }
    769826
    770     private function in_object($value,$object) {
     827    private function in_object($value, $object)
     828    {
    771829        if (is_object($object)) {
    772             foreach($object as $item) {
    773                 if ($value->getAttribute('class')==$item->getAttribute('class') && $item->nodeName!='body' ) return true;
     830            foreach ($object as $item) {
     831                if ($value->getAttribute('class') == $item->getAttribute('class') && $item->nodeName != 'body') return true;
    774832            }
    775833        }
     
    780838    {
    781839        $articleContent = array(
    782             "article_html"=>array(),
    783             "links"=>array(),
    784             "domains"=>array(),
    785             "images"=>array(),
    786             "keywords"=>array(),
    787             "titles"=>array()
     840            "article_html" => array(),
     841            "links" => array(),
     842            "domains" => array(),
     843            "images" => array(),
     844            "keywords" => array(),
     845            "titles" => array()
    788846        );
    789847        // TODO make sure this cleanup can be done earlier or later, or maybe shall not affect the base dom with original html at all
     
    791849        $main_article = $this->xpath->query("//*[contains(@class, 'hentry')]");
    792850        $main_article = ($main_article->length > 0) ? $main_article->item(0) : $this->xpath->query('//body')->item(0);
    793         foreach($this->articles as $article){
    794             $this->getArticlesContent($article,$articleContent);
    795             if(isset($article->parentNode)){
     851        foreach ($this->articles as $article) {
     852            $this->getArticlesContent($article, $articleContent);
     853            if (isset($article->parentNode)) {
    796854                $article->parentNode->removeChild($article);
    797855            }
    798856        }
    799857
    800         if(!$this->in_object($main_article,$this->articles)){
    801             $this->getArticlesContent($main_article,$articleContent);
    802         }
    803         foreach($articleContent as $key => $article_info){
     858        if (!$this->in_object($main_article, $this->articles)) {
     859            $this->getArticlesContent($main_article, $articleContent);
     860        }
     861        foreach ($articleContent as $key => $article_info) {
    804862            $articleContent[$key] = array_reverse($article_info);
    805863        }
     
    808866    }
    809867
    810     private function getArticlesContent($article,&$articleContent){
    811         $comments = $this->xpath->query(".//comment()",$article);
    812         foreach($comments as $comment){
     868    private function getArticlesContent($article, &$articleContent)
     869    {
     870        $comments = $this->xpath->query(".//comment()", $article);
     871        foreach ($comments as $comment) {
    813872            $comment->parentNode->removeChild($comment);
    814873        }
    815         $input = $this->xpath->query(".//node()[name()='iframe' or name()='input' or name()='button' or name='textarea' or name()='form']",$article);
     874        $input = $this->xpath->query(".//node()[name()='iframe' or name()='input' or name()='button' or name='textarea' or name()='form']", $article);
    816875        foreach ($input as $inp) {
    817876            $inp->parentNode->removeChild($inp);
    818877        }
    819         $art = $this->xpath->query('.//article',$article);
    820         if($art->length>0){
    821             foreach($art as $artcl){
     878        $art = $this->xpath->query('.//article', $article);
     879        if ($art->length > 0) {
     880            foreach ($art as $artcl) {
    822881                $artcl->parentNode->removeChild($artcl);
    823882            }
     
    828887        foreach ($imgTags as $t) {
    829888            $src = $t->getAttribute('src');
    830             $src = !empty($src)? $src : $t->getAttribute('data-src');
    831             $src = !empty($src)? $src : $t->getAttribute('data-src-template');
    832 
    833             if(empty($src)) {
    834                 $styles = explode(';',$t->getAttribute('style'));
     889            $src = !empty($src) ? $src : $t->getAttribute('data-src');
     890            $src = !empty($src) ? $src : $t->getAttribute('data-src-template');
     891
     892            if (empty($src)) {
     893                $styles = explode(';', $t->getAttribute('style'));
    835894                preg_match("/url[\s]*\(([\'\"]*)([^\'\")]*)/i", $styles[0], $output);
    836                 if(!empty($output)) $src = $output[2];
     895                if (!empty($output)) $src = $output[2];
    837896            }
    838897            if (strlen($src) > 3) {
     
    861920        }
    862921        $articleContent['images'][] = $result_images;
    863         $title_node = $this->xpath->query('.//node()[name()="h1"]',$article);
     922        $title_node = $this->xpath->query('.//node()[name()="h1"]', $article);
    864923        $title = "";
    865         if($title_node->length > 0){
     924        if ($title_node->length > 0) {
    866925            $title = $title_node->item(0)->nodeValue;
    867         }
    868         else{
    869             $title_node = $this->xpath->query('.//node()[name()="h2"]',$article);
    870             if($title_node->length > 0){
     926        } else {
     927            $title_node = $this->xpath->query('.//node()[name()="h2"]', $article);
     928            if ($title_node->length > 0) {
    871929                $title = $title_node->item(0)->nodeValue;
    872             }
    873             else{
    874                 $title_node = $this->xpath->query('.//*[contains(@class,"title")]',$article);
     930            } else {
     931                $title_node = $this->xpath->query('.//*[contains(@class,"title")]', $article);
    875932                $title = $title_node->item(0)->nodeValue;
    876933            }
    877934        }
    878935        $articleContent['titles'][] = trim($title);
    879         if(isset($title_node->item(0)->parentNode)){
     936        if (isset($title_node->item(0)->parentNode)) {
    880937            $title_node->item(0)->parentNode->removeChild($title_node->item(0));
    881938        }
    882939        $articleContent['article_html'][] = $this->dom->saveXML($article);
    883         $link = ($this->xpath->query('.//a',$article)->length > 0)?$this->xpath->query('.//a',$article)->item(0)->getAttribute('href'):"";
    884         $link = (strpos($link, '/')==0)? $this->domain.$link : $link;
    885         $articleContent['links'][] = (!empty($link))? $link : "";
    886         $articleContent['domains'][] = (!empty($link))? parse_url($link,PHP_URL_SCHEME) ."://". parse_url($link,PHP_URL_HOST) : "";
     940        $link = ($this->xpath->query('.//a', $article)->length > 0) ? $this->xpath->query('.//a', $article)->item(0)->getAttribute('href') : "";
     941        $link = (strpos($link, '/') == 0) ? $this->domain . $link : $link;
     942        $articleContent['links'][] = (!empty($link)) ? $link : "";
     943        $articleContent['domains'][] = (!empty($link)) ? parse_url($link, PHP_URL_SCHEME) . "://" . parse_url($link, PHP_URL_HOST) : "";
    887944        //smart tags
    888945        $smart_tags = array();
     
    895952            foreach ($defined_tags as $tag) {
    896953                $tag = trim($tag);
    897                 $count = $this->countMatches($tag,$title,$article->nodeValue);
     954                $count = $this->countMatches($tag, $title, $article->nodeValue);
    898955                if ($count > 0) {
    899956                    $smart_tags[$tag] = $count;
     
    904961        if (count($this->keywords)) {
    905962            foreach ($this->keywords as $key => $keyword) {
    906                 $count = $this->countMatches($key,$title,$article->nodeValue);
     963                $count = $this->countMatches($key, $title, $article->nodeValue);
    907964                if ($count > 0) {
    908965                    $smart_tags[$keyword] = $count;
     
    916973        $articleContent['keywords'][] = $smart_tags;
    917974    }
    918     private function countMatches($keyword,$title=false,$content=false)
     975
     976    private function countMatches($keyword, $title = false, $content = false)
    919977    {
    920978        $total_occurrence = 0;
    921979        $tag_in_title = array();
    922980        $tag_in_content = array();
    923         $title = (!empty($title))? $title: $this->title;
    924         $content = (!empty($content))? $content : $this->data;
     981        $title = (!empty($title)) ? $title : $this->title;
     982        $content = (!empty($content)) ? $content : $this->data;
    925983        preg_match_all("/(?<!\w)(?=[^>]*(<|$))" . $keyword . "/i", $title, $tag_in_title);
    926984        preg_match_all("/(?<!\w)(?=[^>]*(<|$))" . $keyword . "/i", $content, $tag_in_content);
     
    928986        return $total_occurrence;
    929987    }
    930 
    931988
    932989
  • expresscurate/trunk/ExpressCurate_Sitemap.php

    r1162493 r1179063  
    157157                die;
    158158            } else {
    159                 $response = array('status'=> 3,'message' => 'ExpressCurate shall be authorized to access to Google Webmaster Tools.');
     159                $response = array('status'=> 3,'message' => 'ExpressCurate shall be authorized to access to Google Search Console (aka Webmaster Tools).');
    160160            }
    161161       }
  • expresscurate/trunk/ExpressCurate_SocialManager.php

    r1172885 r1179063  
    1616    const SOCIAL_APPROVED_POST_MESSAGES_META = '_expresscurate_social_approved_post_messages';
    1717    const SOCIAL_POST_MESSAGES_META = '_expresscurate_social_post_messages';
     18    const SOCIAL_POST_COUNTER = '_expresscurate_social_post_counter';
    1819
    1920    const APPROVED = 'approved';
     
    3738
    3839        return self::$instance;
     40    }
     41
     42    public function saveSocialPublishingStatus() {
     43        $data = $_REQUEST;
     44        $status = $data['status'];
     45        if($status == 'off'){
     46            update_option('expresscurate_buffer_access_token', '');
     47        }
     48        update_option('expresscurate_social_publishing', $status);
    3949    }
    4050
     
    120130        }
    121131
     132        $publishedPostMessages = $this->getPublishedPostMessages($post_id);
     133
    122134        update_post_meta($post_id, self::SOCIAL_APPROVED_POST_MESSAGES_META, $approved);
    123135        update_post_meta($post_id, self::SOCIAL_POST_MESSAGES_META, $allMessages);
     136        update_post_meta($post_id, self::SOCIAL_POST_COUNTER, count($approved)+count($publishedPostMessages));
    124137    }
    125138
     
    142155        // save the new statuses
    143156        update_post_meta($post_id, self::SOCIAL_PUBLISHED_POST_MESSAGES_META, $publishedPostMessages);
    144         update_post_meta($post_id, self::SOCIAL_APPROVED_POST_MESSAGES_META, '');
     157        update_post_meta($post_id, self::SOCIAL_APPROVED_POST_MESSAGES_META, null);
     158        update_post_meta($post_id, self::SOCIAL_POST_COUNTER, count($publishedPostMessages));
    145159    }
    146160}
  • expresscurate/trunk/ExpressCurate_Tags.php

    r1137344 r1179063  
    1616
    1717        if ((strpos($matches[3], '</a') < strpos($matches[3], '<a')) || strpos($matches[3], '.') !== false) {
    18             return '<a class="expresscurate_contentTags" href="' . get_tag_link($this->tag_id) . '">#' . strtolower($matches[0]) . '</a>';
     18            return '<a class="expresscurate_contentTags" href="' . get_tag_link($this->tag_id) . '">#' . $matches[0]. '</a>';
    1919        } else {
    2020            return $matches[0];
  • expresscurate/trunk/css/expresscurate.css

    r1172885 r1179063  
    638638        .expresscurate_feed_dashboard .addFeed span span,
    639639        .expresscurate_keywords_settings .addKeywords span span,
     640        .expresscurate_settings .addUsers span span,
     641        .expresscurate_settings .addKeywords span span,
    640642        .expresscurate_widget_wrapper .addKeywords span span{
    641643            background: url("../images/plus.svg") no-repeat transparent center;
     
    12321234    z-index: 90000;
    12331235}
    1234 
     1236.expresscurate_settings .addUsers,
     1237.expresscurate_settings .addKeywords{
     1238    width: 200px;
     1239    height: 30px;
     1240    overflow: hidden;
     1241    margin: 0;
     1242    position: relative;
     1243}
     1244
     1245    .expresscurate_settings .addUsers input,
     1246    .expresscurate_settings .addKeywords input,
    12351247    .expresscurate_widget_wrapper .addKeywords input {
    12361248        height: 100%;
     
    12461258        border: none;
    12471259    }
     1260    .expresscurate_settings .addUsers input,
     1261    .expresscurate_settings .addKeywords input{
     1262        font-size: 12px;
     1263        line-height: 25px;
     1264    }
    12481265.expresscurate_widget_wrapper .addKeywords input::-webkit-input-placeholder,
    12491266.expresscurate_widget_wrapper .addKeywords input:-moz-placeholder {
     
    12511268    line-height: 14px;
    12521269}
     1270    .expresscurate_settings .addUsers span ,
     1271    .expresscurate_settings .addKeywords span ,
    12531272    .expresscurate_widget_wrapper .addKeywords span {
    12541273        height: 35px;
     
    12651284        cursor: pointer;
    12661285    }
     1286    .expresscurate_settings .addUsers span,
     1287    .expresscurate_settings .addKeywords span{
     1288        height: 30px;
     1289        width: 30px;
     1290    }
     1291.expresscurate_settings .addUsers span:hover,
     1292.expresscurate_settings .addKeywords span:hover,
    12671293.expresscurate_widget_wrapper .addKeywords span:hover{
    12681294    background-color: #20d0b1;
    12691295}
     1296/*.expresscurate_settings .addKeywords ::-webkit-input-placeholder,*/
    12701297.expresscurate_widget_wrapper ::-webkit-input-placeholder {
    12711298    padding-top: 3px;
     
    29422969.expresscurate .tab-content > div{
    29432970    min-height: 70vh;
    2944     max-width: 800px;
     2971    max-width: 1000px;
    29452972}
    29462973.expresscurate_advancedSEO_widget .tab-link.disabled,
     
    30773104    margin: 0 0 0 5px;
    30783105}
    3079 
     3106.expresscurate .socialPublishingWrap{
     3107    margin-left: 30px;
     3108}
     3109    .expresscurate .socialPublishingWrap li{
     3110        display: inline-block;
     3111    }
     3112/*feed stop words*/
     3113    .expresscurate_settings .usersToAlert li,
     3114    .expresscurate_settings .stopKeywords li{
     3115        display: inline-block;
     3116        border: solid 1px #E6E6E6;
     3117        height: 30px;
     3118        margin: 0 5px 5px 0 ;
     3119        position: relative;
     3120        padding: 0 40px 0 10px;
     3121        line-height: 28px;
     3122        box-sizing: border-box;
     3123        -moz-box-sizing: border-box;
     3124        -webkit-box-sizing: border-box;
     3125        vertical-align: top;
     3126    }
     3127        .expresscurate_settings .usersToAlert li span,
     3128        .expresscurate_settings .stopKeywords li span{
     3129            position: absolute;
     3130            width: 30px;
     3131            height: 30px;
     3132            display: inline-block;
     3133            color: #fefefe;
     3134            font-size: 30px;
     3135            text-align: center;
     3136            line-height: 30px;
     3137            right: 0;
     3138            top: -1px;
     3139            box-sizing: border-box;
     3140            -moz-box-sizing: border-box;
     3141            -webkit-box-sizing: border-box;
     3142            cursor: pointer;
     3143            background: url("../images/remove.svg") #1cbb9f no-repeat center;
     3144            background-size: 16px auto;
     3145        }
     3146/**/
    30803147.expresscurate .form-table {
    30813148    margin-left: 25px;
     
    51255192        background-position: 6px -64px;
    51265193    }
    5127     .expresscurate_social_box_Twitter:hover{
    5128         background-color: rgba(0,172,273,0.8);
    5129     }
    51305194    .expresscurate_social_box_Facebook{
    51315195        background-color: rgba(59,89,152,1);
    51325196        background-position: 5px 0;
    51335197    }
    5134     .expresscurate_social_box_Facebook:hover{
    5135         background-color: rgba(59,89,152,0.8);
    5136     }
    51375198    .expresscurate_social_box_LinkedIn{
    51385199        background-color: rgba(30,135,189,1);
    51395200        background-position: 6px -173px;
    51405201    }
    5141     .expresscurate_social_box_LinkedIn:hover{
    5142         background-color: rgba(30,135,189,0.8);
    5143     }
    51445202    .expresscurate_social_box_Google{
    51455203        background-color: rgba(212,65,50,1);
    51465204        background-position: 7px -120px;
    5147     }
    5148     .expresscurate_social_box_Google:hover{
    5149         background-color: rgba(212,65,50,0.8);
    51505205    }
    51515206        .expresscurate_social_box .dailySuggestions{
  • expresscurate/trunk/css/theme-styles.css

    r1106118 r1179063  
    113113    resize:both;
    114114}
    115 
    116 .expresscurate_FacebookEmbed{
    117     width: 500px;
    118     height: 300px;
    119     background-image: url("../images/noimage.png");
    120 }
  • expresscurate/trunk/js/Buttons.js

    r1172885 r1179063  
    183183        messageHtml += arrOutboundLinks ? '' : '<p class="lengthSuggestion blue">This page contains no outbound links, add some where appropriate.</p>';
    184184
     185        /*social post*/
     186        if($('#expresscurate_social_publishing').length){
     187            if($('.expresscurate_socialPostBlock').length<1){
     188                messageHtml+='<p class="lengthSuggestion blue">You currently have no social posts. Add a couple of them to get more exposure.</p>';
     189            }
     190        }
     191
    185192        /*keywords validation*/
    186193        var defKeywords = $('#expresscurate_defined_tags').val();
     
    313320        var $this = $('#expresscurate_socialEmbed'),
    314321            content = $this.val().trim(),
    315             $tabs = $('.expresscurate_socialDialog .tabs li');
    316         $.each($tabs, function (index, value) {
    317             var tab = $(value).data('tab'),
    318                 myRegExp = new RegExp('https?:\/\/([a-zA-Z\d-]+\.){0,}' + tab + '\.com', 'gmi');
     322            $tabs = $('.expresscurate_socialDialog .tabs li'),
     323            names = ['youtube', 'youtu', 'vimeo', 'facebook', 'twitter'];
     324        $.each(names, function (index, value) {
     325            var tab = value,
     326                myRegExp = new RegExp('https?:\/\/([a-zA-Z\d-]+\.){0,}' + tab + '(\.com|\.be)', 'gmi');
    319327            if (myRegExp.test(content)) {
    320328                $tabs.removeClass('current');
     329                if(tab=='youtu'){
     330                    tab='youtube';
     331                }
    321332                $('.expresscurate_socialDialog .tabs li.' + tab).addClass('current');
    322333            }
     
    345356            ($contentWrap.css("display") === "block") ? $contentWrap.focus() : tinyMCE.get("content").focus();
    346357            var ed = tinymce.activeEditor;
     358            ExpressCurateUtils.track('/post/embed-dialog/open');
    347359            ed.windowManager.open({
    348360                title: 'Embed',
     
    391403                                    break;
    392404                            }
     405                            ExpressCurateUtils.track('/post/embed-dialog/insert' + selectedTab);
    393406                            if (url) {
    394407                                if ($contentWrap.css("display") === "block") {
     
    634647                    ed.addCommand('addSocialPost', function () {
    635648                        if (tinymce.activeEditor.selection.getContent().length > 1) {
     649                            ExpressCurateUtils.track('/post/social-post-widget/getselection');
    636650                            var text = tinymce.activeEditor.selection.getContent(),
    637651                                myRegExp = new RegExp('(<([^>]+)>)', 'ig');
  • expresscurate/trunk/js/Dialog.js

    r1162493 r1179063  
    393393                                displayCuratedTags(keywords);
    394394                            }
     395                            ExpressCurateUtils.track('/post/content-dialog/cloneload');
    395396                        } else {
    396397                            if (data.result.title && data.result.title.length > 0) {
  • expresscurate/trunk/js/Settings.js

    r1162493 r1179063  
    2222    }
    2323
     24    function addSettingsListItems($this) {
     25        var $stopKeywordsWrap = $this.parents('.controls'),
     26            $input = $stopKeywordsWrap.find('input'),
     27            $list = $stopKeywordsWrap.find('.defItems'),
     28            $definedWrap = $stopKeywordsWrap.find('> textarea'),
     29            keywords = ExpressCurateKeywordUtils.multipleKeywords($input, $list, $definedWrap);
     30
     31        $.each(keywords, function (key, value) {
     32            $list.append('<li>' + value + '<span class="close"></span></li>');
     33        });
     34    }
     35
    2436    function setupSettings() {
    2537        var $submitSitemap = $('.expresscurate #submitSiteMap');
     
    3850                $publishDiv.stop(true, true).slideUp('slow');
    3951            }
    40 
    4152        });
    4253        /*settings page traching*/
     
    6172        });
    6273        /*social publishing*/
    63         $('#expresscurate_social_publishing').on('change', function () {
     74        $('.expresscurate_settings #expresscurate_social_publishing').on('change', function () {
     75            var $this = $(this),
     76                $token = $('#expresscurateBufferAccessToken'),
     77                status = $this.is(':checked') ? 'on' : 'off';
    6478            showHideOptions($('.socialPublishingWrap'), $(this));
     79            if ($this.is(':checked')) {
     80                $token.removeClass('expresscurate_displayNone');
     81            } else {
     82                $token.addClass('expresscurate_displayNone');
     83            }
     84
     85            $.ajax({
     86                type: 'POST',
     87                url: 'admin-ajax.php?action=expresscurate_save_social_publishing_status',
     88                data: {status: status}
     89            });
    6590        });
    6691        $('html').on('change', '.expresscurate_social_publishing_profile', function () {
     
    86111        });
    87112
     113        /*stop keywords for feed*/
     114        $('.expresscurate_settings .addKeywords input').on('keyup', function (e) {
     115
     116            var $this = $(this);
     117            e.preventDefault();
     118            e.stopPropagation();
     119            if (e.keyCode === 13) {
     120                addSettingsListItems($this);
     121            }
     122        });
     123        $('.expresscurate_settings .addKeywords span span').on('click', function () {
     124            addSettingsListItems($(this));
     125        });
     126
     127        $('.expresscurate_settings .stopKeywords').on('click', ' li span', function () {
     128            var $this = $(this),
     129                $elem = $this.parent('li'),
     130                $defWrap = $this.parents('.controls').find(' > textarea');
     131            ExpressCurateKeywordUtils.close(ExpressCurateKeywordUtils.justText($elem), $elem, $defWrap);
     132        });
     133        /*content alert users*/
     134        $('.expresscurate_settings .addUsers input').on('keyup', function (e) {
     135            var $this = $(this),
     136                allUsers = $('#expresscurate_allUsers').val().split(',');
     137            $this.autocomplete({source: allUsers});
     138
     139            if (e.keyCode === 13) {
     140                if ($.inArray($this.val(), allUsers) > -1) {
     141                    addSettingsListItems($this);
     142                }
     143            }
     144        });
     145        $('.expresscurate_settings .addUsers span span').on('click', function () {
     146            var $this = $(this),
     147                $user = $this.parents('.addUsers').find('input'),
     148                allUsers = $('#expresscurate_allUsers').val().split(',');
     149
     150            if ($.inArray($user.val(), allUsers) > -1) {
     151                addSettingsListItems($this);
     152            }
     153        });
     154
     155        $('.expresscurate_settings .usersToAlert').on('click', ' li span', function () {
     156            var $this = $(this),
     157                $elem = $this.parent('li'),
     158                $defWrap = $this.parents('.controls').find(' > textarea');
     159            ExpressCurateKeywordUtils.close(ExpressCurateKeywordUtils.justText($elem), $elem, $defWrap);
     160        });
    88161        /*sitemap*/
    89162        $('#expresscurate_sitemap_submit').on('change', function () {
     
    120193                } else {
    121194                    $submitSitemap.addClass('expresscurate_displayNone').removeClass('generated');
    122                     $submitSitemap.after('<p class="expresscurate_Error expresscurate_SettingsError">Something went wrong. Please, make sure you have authorized ExpressCurate to access to Google Webmaster Tools.</p>');
     195                    $submitSitemap.after('<p class="expresscurate_Error expresscurate_SettingsError">Something went wrong. Please, make sure you have authorized ExpressCurate to access to Google Search Console (aka Webmaster Tools).</p>');
    123196                }
    124197            });
     
    175248            $(this).next('span').children('a').attr('href', rest + $(this).val());
    176249        });
     250
     251
     252        $('.expresscurate_settings').keydown(function (event) {
     253            if (event.keyCode === 13) {
     254                event.preventDefault();
     255                return false;
     256            }
     257        });
    177258    }
    178259
  • expresscurate/trunk/js/keywords/KeywordUtils.js

    r1106118 r1179063  
    22    var autoCompleteRequest;
    33
    4     function checkKeyword(text, listName) {
     4    function checkKeyword(text, listName,defElem) {
    55        if (text !== '') {
    66            text = text.replace(/[,.;:?!]+/g, '').trim();
    7             var $defTags = $('textarea[name=expresscurate_defined_tags]'),
     7            var $defTags =defElem ? defElem : $('textarea[name=expresscurate_defined_tags]'),
    88                defVal = justText($defTags).replace(/\s{2,}/g, ' '),
    99                $widget = $('#expresscurate_widget'),
    10                 $errorMessage=$widget.find('.expresscurate_errorMessage'),
    11                 defValArr = defVal.split(', '),
    12                 rslt;
     10                $errorMessage = $widget.find('.expresscurate_errorMessage'),
     11                defValArr = defVal.split(', ');
    1312            $errorMessage.remove();
    1413            if (text.length < 3 && $widget.length) {
    1514                $errorMessage.text('This keyword is too short.  We recommend keywords with at least 3 characters.');
    1615            } else {
    17                 rslt = null;
    1816                for (var i = 0; i < defValArr.length; i++) {
    1917                    if (defValArr[i].toLowerCase() === text.toLowerCase()) {
    20                         rslt = (i + 1);
    2118                        if ($widget.length > 0) {
    2219                            highlight(text, $widget.find(' .statisticsTitle'));
     
    2623                        text = '';
    2724                        break;
    28                     } else {
    29                         rslt = -1;
    3025                    }
    3126                }
     
    4944    }
    5045
    51     function multipleKeywords(el, listName) {
     46    function multipleKeywords(el, listName,defElem) {
    5247        var keywords = '',
    5348            arr,
     
    6358        arr = keywords.split(/,|:|;|[\\.]/);
    6459        for (var i = 0; i < arr.length; i++) {
    65             var checkedKeyword = checkKeyword(arr[i], listName);
     60            var checkedKeyword = checkKeyword(arr[i], listName,defElem);
    6661            if (checkedKeyword.length > 0) {
    6762                result.push(checkedKeyword);
     
    7166    }
    7267
    73     function close(keyword, elemToRemove) {
    74         var $defTags = $('textarea[name=expresscurate_defined_tags]'),
    75             newVal = justText($defTags).toLocaleLowerCase(),
    76             lastChar = '';
    77 
    78         newVal = newVal.replace(keyword.toLocaleLowerCase(), '');
    79         newVal = newVal.replace(', ,', ',');
     68    function close(keyword, elemToRemove, defElem) {
     69
     70        var $defTags =defElem ? defElem : $('textarea[name=expresscurate_defined_tags]'),
     71            newVal = justText($defTags).toLocaleLowerCase().trim(),
     72            lastChar = '',
     73            myRegExp = new RegExp('(, |^)' + keyword.toLocaleLowerCase() + '(,|$)', 'gmi');
     74
     75        newVal = newVal.replace(myRegExp, '');
    8076        lastChar = newVal.slice(-2);
    8177        if (lastChar === ', ') {
     
    131127            var liHTML = '',
    132128                text = input.val(),
    133                 $autoComplete=$('.suggestion');
     129                $autoComplete = $('.suggestion');
    134130            if (autoCompleteRequest && autoCompleteRequest.readystate !== 4) {
    135131                autoCompleteRequest.abort();
  • expresscurate/trunk/js/keywords/Keywords.js

    r1129694 r1179063  
    153153            var matches = ed.getBody(),
    154154                i = 0;
     155
    155156            keywords = keywords.sort(function (a, b) {
    156                 return b > a
    157             });
     157                return b.length > a.length
     158            });
     159
    158160            keywords.forEach(function (val) {
    159161                $(matches).html(function (index, oldHTML) {
  • expresscurate/trunk/js/keywords/SEOControlCenter.js

    r1137344 r1179063  
    284284                $noFollow.add($noIndex).attr('disabled',false);
    285285            }
     286
     287            ExpressCurateUtils.track('/post/seo-control-center/clonestatuschange');
    286288        });
    287289        $('.expresscurate_moveToAdvanced').on('click', function () {
  • expresscurate/trunk/js/socialPostWidget.js

    r1172885 r1179063  
    1414        var $contentWrap = $('#content'),
    1515            content = (($contentWrap.css("display") === "block") ? $contentWrap.val() : tinyMCE.get("content").getContent()),
    16             myRegExp = new RegExp('(<([^>]+)>)', 'ig');
     16            myRegExp = new RegExp('(<([^>]+)>)', 'ig'),
     17            li = $(content).find('li'),
     18            posts = [];
     19
     20        if (li.length) {
     21            $.each(li, function (index, value) {
     22                var text = $(value).text();
     23                posts.push(text);
     24                content = content.replace(text, '');
     25            });
     26        }
    1727
    1828        content = content.split('<p>');
     
    2030            content[i] = content[i].replace(myRegExp, ' ').trim();
    2131        }
    22         content = content.filter(function (el) {
     32
     33        var result = $.merge(posts, content);
     34        result = result.filter(function (el) {
    2335            return el.length !== 0;
    2436        });
    2537
    26         return content;
     38        return result;
    2739    }
    2840
     
    3345                message: $(content).find(header).text()
    3446            };
     47        ExpressCurateUtils.track('/post/social-post-widget/get' + header);
    3548        if (data.message.length > 1) {
    3649            createSocialPost(data);
     
    114127                if (value.id == blockId) {
    115128                    value.message = text;
     129                    value.postLength = maxLength - text.length;
    116130                    updatePosts(posts);
    117131                }
     
    150164                createSocialPost(data);
    151165            });
     166            ExpressCurateUtils.track('/post/social-post-widget/getcontent');
    152167        });
    153168        /*add new*/
    154169        $('#expresscurate_addTweet').on('click', function () {
    155170            createSocialPost(null);
     171            ExpressCurateUtils.track('/post/social-post-widget/createnew');
    156172        });
    157173        /*post from headers*/
     
    166182                    message: $('#expresscurate_advanced_seo_social_title').val()
    167183                };
     184                ExpressCurateUtils.track('/post/social-post-widget/socialtitle');
    168185                createSocialPost(data);
    169186            }
     
    176193                    message: $('#expresscurate_advanced_seo_social_desc').val()
    177194                };
     195                ExpressCurateUtils.track('/post/social-post-widget/socialdescription');
    178196                createSocialPost(data);
    179197            }
     
    186204                    message: $('#expresscurate_advanced_seo_social_shortdesc').val()
    187205                };
     206                ExpressCurateUtils.track('/post/social-post-widget/socialshortdescription');
    188207                createSocialPost(data);
    189208            }
     
    206225                }
    207226            });
    208 
     227            ExpressCurateUtils.track('/post/social-post-widget/approve');
    209228            updatePosts(posts);
    210229
     
    247266            var clone = $.extend({}, post);
    248267            clone.id = uniqueId();
     268            clone.postLength = maxLength - clone.message.length;
    249269            posts.push(clone);
    250 
    251             updatePosts(posts);
    252             $('.mainControls').after(ExpressCurateUtils.getTemplate('socialPostWidget', post));
    253 
    254 
    255         });
    256 
     270            ExpressCurateUtils.track('/post/social-post-widget/copy');
     271            updatePosts(posts);
     272            $block.before(ExpressCurateUtils.getTemplate('socialPostWidget', post));
     273        });
    257274    }
    258275
  • expresscurate/trunk/readme.txt

    r1172885 r1179063  
    11=== ExpressCurate ===
    22Contributors: expresscurate
    3 Tags: content curation, content marketing, curation plugin, content curation plugin, curation tools, content curation tools, content curation toolkit, content writing, attribution, content, curation, curating, rss, feed, keywords summary, keywords dashboard, seo control center, keyword, seo, sitemap, google webmasters, google, widget, bookmark
     3Tags: content curation, content marketing, curation plugin, content curation plugin, curation tools, content curation tools, content curation toolkit, content writing, attribution, content, curation, curating, rss, feed, keywords summary, keywords dashboard, seo control center, keyword, seo, sitemap, search console, google, widget, bookmark, social, twitter
    44Donate link: https://bit.ly/expresscuratedonate
    55Requires at least: 3.9
    66Tested up to: 4.2.2
    7 Stable tag: 2.1.0
     7Stable tag: 2.1.1
    88License: GPLv3 or later
    99License URI: http://www.gnu.org/licenses/gpl.html
     
    8181
    8282= How To Get Started =
    83 [Download ExpressCurate plugin](http://downloads.wordpress.org/plugin/expresscurate.2.1.0.zip "Your favorite content marketing tools") for WordPress. 
     83[Download ExpressCurate plugin](http://downloads.wordpress.org/plugin/expresscurate.2.1.1.zip "Your favorite content marketing tools") for WordPress. 
    8484You can also [download](http://www.expresscurate.com/p/products/wordpress-theme "Your favorite WordPress Theme") a **free** [ExpressCurate WordPress theme](http://www.expresscurate.com/p/products/wordpress-theme "Your favorite WordPress Theme"). It will give your curated content a modern online news look.
    8585
     
    11311305. Post - Curate Content: Load the passages of choice into the post, and curate!
    11411406. Post - Styling, Editing, Analytics: When editing a post, use the toolbar for keyword highlights, box styles and access to post analysis.
    115 07. Post - Embed: Provide an embed code from Facebook,  Twitter, YouTube or Vimeo and have the proper card inserted into your post.
     11507. Post - Embed: Provide an embed code from Facebook, Twitter, YouTube or Vimeo and have the proper card inserted into your post.
    11611608. Post - Embed: Embed multiple posts to create stories.
    11711709. Post - SEO Control Center: Pick relevant keyword density and create meta descriptions using the SEO Control Center.
     
    11911911. Post Analysis: Use Post analysis to receive improvement suggestions for your content!
    12012012. Post - Sources: Access the list of Sources from which content is pulled and check for the number of posts curated from these sources.
    121 13. Keywords Dashboard
    122 14. RSS Feeds
    123 15. Top Sources
    124 16. Settings
    125 17. FAQ: See FAQs for common usage hints and questions.
     12113. Social Publishing Widget: Use the social publishing widget for social media promotions, content optimization & sharing.
     12214. Keywords Dashboard
     12315. RSS Feeds
     12416. Top Sources
     12517. Settings
     12618. FAQ: See FAQs for common usage hints and questions.
    126127
    127128
     
    130131
    131132== Changelog ==
     133
     134= 2.1.1 =
     135* New Setting: Stop Keywords. Content Feed will filter out the posts that contain these stop words.
     136* New Setting: Content Alert Users. Content (Keyword Match) Alert will be sent to the specified users only.
     137* New Feature: All Posts now shows the number of approved social promotion messages.
     138* Miscellaneous bug fixes and improvements.
    132139
    133140= 2.1.0 =
  • expresscurate/trunk/templates/dashboard.php

    r1172885 r1179063  
    2727    <div class="expresscurate_blocksContainer expresscurate_masonryWrap">
    2828        <?php
    29         $dashboard_order = get_option('dashboard_items_order');
     29        $dashboard_order = get_option('dashboard_items_order') ? get_option('dashboard_items_order') : array();
     30        $allWidgets = array('keyWords', 'keyWordsIntOverTime', 'keyWordsRelTopics', 'smartPublish', 'socialPublish', 'feedWidget', 'bookmarks', 'support');
     31        foreach ($allWidgets as $item) {
     32            if (!in_array($item, $dashboard_order)) {
     33                $dashboard_order[] = $item;
     34            }
     35        }
    3036        if (!empty($dashboard_order)) {
    3137            foreach ($dashboard_order as $ordered_item):
     
    103109                endif;
    104110            endforeach;
    105         } else {
    106             ?>
    107             <div id='keyWords' class="expresscurate_keywordsBlock expresscurate_masonryItem">
    108                 <label class="label">Keywords Summary</label>
    109                 <?php $this->keywords_widget(); ?>
    110             </div>
    111 
    112             <div id='keyWordsIntOverTime' class="expresscurate_keywordsBlock expresscurate_masonryItem">
    113                 <label class="label">Keywords Interest Over Time</label>
    114                 <?php $this->keywords_interest_over_time_widget(); ?>
    115             </div>
    116 
    117             <div id='keyWordsRelTopics' class="expresscurate_keywordsBlock expresscurate_masonryItem">
    118                 <label class="label">Keywords Related Topics</label>
    119                 <?php $this->keywords_related_topics_widget(); ?>
    120             </div>
    121 
    122             <?php
    123             if (get_option('expresscurate_publish', '') == "on") { ?>
    124                 <div id="smartPublish" class="expresscurate_smartPublishBlock expresscurate_masonryItem">
    125                     <label class="label">Smart Publishing Overview</label>
    126                     <?php $this->smart_publishing_widget(); ?>
    127                 </div>
    128             <?php } ?>
    129 
    130             <?php
    131             if (get_option('expresscurate_social_publishing', '') == "on" && strlen(get_option('expresscurate_buffer_access_token')) > 2) { ?>
    132                 <div id="socialPublish" class="expresscurate_socialPublishBlock expresscurate_masonryItem">
    133                     <label class="label">Social Publishing Overview</label>
    134                     <?php $this->social_publishing_widget(); ?>
    135                 </div>
    136             <?php } ?>
    137 
    138             <div id="feedWidget" class="expresscurate_feedBlock expresscurate_masonryItem">
    139                 <label class="label">Feed</label>
    140                 <?php $this->feed_widget(); ?>
    141             </div>
    142 
    143             <div id="bookmarks" class="expresscurate_bookmarksBlock expresscurate_masonryItem">
    144                 <label class="label">Bookmarks</label>
    145                 <?php $this->bookmarks_widget(); ?>
    146             </div>
    147 
    148 
    149             <div id='support' class="expresscurate_supportBlock expresscurate_masonryItem">
    150                 <label class="label">Support</label>
    151 
    152                 <div>
    153                     <?php if (!$sent) { ?>
    154                         <label for="expresscurate_support_email">Leave your feedback</label>
    155                     <?php
    156                     } else {
    157                         ?>
    158                         <label for="expresscurate_support_email">Thanks for your feedback</label>
    159                     <?php
    160                     }
    161                     ?>
    162                     <form method="post" action="<?php echo get_admin_url() ?>admin.php?page=expresscurate"
    163                           id="expresscurate_support_form">
    164                         <input id="expresscurate_support_email" name="expresscurate_support_email" class="inputStyle"
    165                                placeholder="Email"
    166                                value="<?php echo $user_email ?>"/>
    167                         <label for="expresscurate_support_email" class="expresscurate_errorMessage"></label>
    168                     <textarea class="inputStyle" name="expresscurate_support_message" id="expresscurate_support_message"
    169                               placeholder="Message"></textarea>
    170                         <label for="expresscurate_support_message" class="expresscurate_errorMessage"></label>
    171                         <a class="feedbackButton send greenBackground" href="#">Send</a>
    172                     </form>
    173                 </div>
    174             </div>
    175         <?php
    176         }
    177         ?>
    178 
    179 
     111        } ?>
    180112    </div>
    181113</div>
  • expresscurate/trunk/templates/dashboard/social_publishing_widget.php

    r1172885 r1179063  
    99            <?php
    1010            if (!empty($profiles)) {
     11                $profilesStatus = array();
     12                if (get_option('expresscurate_social_publishing_profiles', '')) {
     13                    $profilesStatus = json_decode(stripslashes(urldecode(get_option('expresscurate_social_publishing_profiles', ''))));
     14                }
    1115                foreach ($profiles as $i => $profile) {
    12                     $counts = $profile->counts;
    13                     $formatedService= (strpos($profile->formatted_service,'Google') !== false)? 'Google' :$profile->formatted_service;
    14                     ?>
    15                     <li class="expresscurate_background_wrap">
    16                         <div class="expresscurate_social_box expresscurate_social_box_<?php echo $formatedService; ?>">
    17                             <span class="text"><?php echo $profile->formatted_username ?></span>
    18                             <span class="dailySuggestions"><span class="tooltip">daily suggestions</span><?php echo $counts->daily_suggestions; ?></span>
    19                         </div>
    20                         <div title="" class="statistics borderRight">
    21                             <div class="center">sent<br/><span><?php echo $counts->sent; ?></span></div>
    22                         </div>
    23                         <div title="" class="statistics borderRight">
    24                             <div>pending<span><?php echo $counts->pending; ?></span></div>
    25                         </div>
    26                         <div title="" class="statistics">
    27                             <div>drafts<span><?php echo $counts->drafts; ?></span></div>
    28                         </div>
    29                     </li>
     16                    $profileId = $profile->id;
    3017
    31                 <?php
     18                    if ($profilesStatus->$profileId == 'on' || empty($profilesStatus->$profileId)) {
     19                        $counts = $profile->counts;
     20                        $formatedService = (strpos($profile->formatted_service, 'Google') !== false) ? 'Google' : $profile->formatted_service;
     21                        ?>
     22                        <li class="expresscurate_background_wrap">
     23                            <div
     24                                class="expresscurate_social_box expresscurate_social_box_<?php echo $formatedService; ?>">
     25                                <span class="text"><?php echo $profile->formatted_username ?></span>
     26                                <span class="dailySuggestions"><span
     27                                        class="tooltip">daily suggestions</span><?php echo $counts->daily_suggestions; ?></span>
     28                            </div>
     29                            <div title="" class="statistics borderRight">
     30                                <div class="center">sent<br/><span><?php echo $counts->sent; ?></span></div>
     31                            </div>
     32                            <div title="" class="statistics borderRight">
     33                                <div>pending<span><?php echo $counts->pending; ?></span></div>
     34                            </div>
     35                            <div title="" class="statistics">
     36                                <div>drafts<span><?php echo $counts->drafts; ?></span></div>
     37                            </div>
     38                        </li>
     39                    <?php }
     40
    3241                }
    3342            } else {
  • expresscurate/trunk/templates/settings.php

    r1172885 r1179063  
    313313                        <?php
    314314                        $blogName = urlencode(urlencode(get_bloginfo('url')));
     315                        $socialPublishingStatus= get_option('expresscurate_social_publishing', '') == 'On' ? 'On' : 'Off';
    315316                        ?>
    316                         <a class="getApiKey  <?php if (strlen(get_option('expresscurate_buffer_access_token')) > 2) {
    317                             echo 'expresscurate_displayNone';
     317
     318                        <a id="expresscurateBufferAccessToken" class="getApiKey  <?php if (strlen(get_option('expresscurate_buffer_access_token')) > 2 || $socialPublishingStatus=='Off') {
     319                            echo 'expresscurate_displayNone defined';
    318320                        } ?>"
    319321                           href="https://www.expresscurate.com/api/connector/buffer/accesstoken/<?php echo $blogName ?>">Authorize
    320322                            access to Buffer</a>
    321323                    </li>
    322                     <div class="socialPublishingWrap <?php if (get_option('expresscurate_social_publishing', '') !== "on") {
     324                    <div
     325                        class="socialPublishingWrap <?php if (get_option('expresscurate_social_publishing', '') !== "on") {
    323326                            echo 'expresscurate_displayNone';
    324327                        } ?> ">
     
    345348                                           name="expresscurate_social_publishing_<?php echo $profileId; ?>" <?php if ($profilesStatus->$profileId == 'on' || empty($profilesStatus->$profileId)) {
    346349                                        echo 'checked="checked"';
    347                                     }  ?> />
     350                                    } ?> />
    348351                                    <label class="controls checkboxLabel"
    349352                                           for="expresscurate_social_publishing_<?php echo $profileId; ?>"></label>
     
    352355                            }
    353356                            ?>
    354                             <input type="hidden" value="<?php echo stripslashes(get_option('expresscurate_social_publishing_profiles', '')); ?>" id="expresscurate_social_publishing_profiles" name="expresscurate_social_publishing_profiles"/>
     357                            <input type="hidden"
     358                                   value="<?php echo stripslashes(get_option('expresscurate_social_publishing_profiles', '')); ?>"
     359                                   id="expresscurate_social_publishing_profiles"
     360                                   name="expresscurate_social_publishing_profiles"/>
    355361                        <?php
    356362                        }
     
    529535                    <li>
    530536                        <div class="title">
     537                            Stop Keywords
     538                            <div class="description">
     539                                ExpressCurate will filter out the posts that contain any stop keywords.
     540                            </div>
     541                        </div>
     542                        <div class="controls">
     543                            <?php $defStopKeywords = get_option('expresscurate_content_stop_keywords', ''); ?>
     544                            <textarea class="expresscurate_displayNone" name="expresscurate_content_stop_keywords"
     545                                      id="expresscurate_content_stop_keywords" cols="30" rows="10">
     546                                <?php echo $defStopKeywords ?>
     547                            </textarea>
     548                            <ul class="stopKeywords defItems">
     549                                <?php
     550                                $stopKeywords = explode(', ', $defStopKeywords);
     551                                if (!empty($stopKeywords)) {
     552                                    foreach ($stopKeywords as $keyword) {
     553                                        if (!empty($keyword)) {
     554                                            echo '<li>' . $keyword . '<span class="close"></span></li>';
     555                                        }
     556                                    }
     557                                }
     558                                ?>
     559                            </ul>
     560                            <div class="addKeywords">
     561                                <input type="text" placeholder="Add Keywords" class="expresscurate_disableInputStyle"/>
     562                                <span class=""><span></span></span>
     563                                <ul class="suggestion"></ul>
     564                            </div>
     565                        </div>
     566                    </li>
     567                    <li>
     568                        <div class="title">
    531569                            Keyword Match Email Alerts
    532570                            <div class="description">
     
    539577                        <label class="controls checkboxLabel" for="expresscurate_enable_content_alert"></label>
    540578                    </li>
    541                     <li class="emailAlertSlider <?php if (get_option('expresscurate_enable_content_alert') != 'on') echo 'expresscurate_displayNone'; ?>">
    542                         <div class="title">
    543                             Content Alert Frequency
    544                             <div class="description">
    545                                 How frequently should ExpressCurate send content Alert Email (from RSS feeds, Alerts,
    546                                 etc)
    547                             </div>
    548                         </div>
    549                         <select class="controls" id="expresscurate_content_alert_frequency"
    550                                 name="expresscurate_content_alert_frequency">
    551                             <?php
    552                             for ($i = 1; $i < 14; $i++) {
    553                                 ?>
    554                                 <?php if ($i == 1) { ?>
    555                                     <option value="<?php echo $i; ?>" <?php
    556                                     if (get_option('expresscurate_content_alert_frequency') == $i) {
    557                                         echo 'selected="selected"';
    558                                     }
    559                                     ?>>Every hour
    560                                     </option>
    561 
    562                                 <?php } elseif ($i == 13) { ?>
    563                                     <option value="<?php echo $i; ?>" <?php
    564                                     if (get_option('expresscurate_content_alert_frequency') == $i) {
    565                                         echo 'selected="selected"';
    566                                     }
    567                                     ?>>Once a day
    568                                     </option>
    569 
    570                                 <?php } else { ?>
    571                                     <option value="<?php echo $i; ?>" <?php
    572                                     if (get_option('expresscurate_content_alert_frequency') == $i) {
    573                                         echo 'selected="selected"';
    574                                     }
    575                                     ?>>Every <?php echo $i; ?> hours
    576                                     </option>
    577 
    578                                 <?php
    579                                 }
    580                             }
    581                             ?>
    582                         </select>
    583                     </li>
     579                    <div
     580                        class="emailAlertSlider <?php if (get_option('expresscurate_enable_content_alert') != 'on') echo 'expresscurate_displayNone'; ?>">
     581                        <li>
     582                            <div class="title">
     583                                Content Alert Frequency
     584                                <div class="description">
     585                                    How frequently should ExpressCurate send content Alert Emails (from RSS feeds,
     586                                    Alerts,
     587                                    etc)
     588                                </div>
     589                            </div>
     590                            <select class="controls" id="expresscurate_content_alert_frequency"
     591                                    name="expresscurate_content_alert_frequency">
     592                                <?php
     593                                for ($i = 1; $i < 14; $i++) {
     594                                    ?>
     595                                    <?php if ($i == 1) { ?>
     596                                        <option value="<?php echo $i; ?>" <?php
     597                                        if (get_option('expresscurate_content_alert_frequency') == $i) {
     598                                            echo 'selected="selected"';
     599                                        }
     600                                        ?>>Every hour
     601                                        </option>
     602
     603                                    <?php } elseif ($i == 13) { ?>
     604                                        <option value="<?php echo $i; ?>" <?php
     605                                        if (get_option('expresscurate_content_alert_frequency') == $i) {
     606                                            echo 'selected="selected"';
     607                                        }
     608                                        ?>>Once a day
     609                                        </option>
     610
     611                                    <?php } else { ?>
     612                                        <option value="<?php echo $i; ?>" <?php
     613                                        if (get_option('expresscurate_content_alert_frequency') == $i) {
     614                                            echo 'selected="selected"';
     615                                        }
     616                                        ?>>Every <?php echo $i; ?> hours
     617                                        </option>
     618
     619                                    <?php
     620                                    }
     621                                }
     622                                ?>
     623                            </select>
     624
     625                        </li>
     626                        <li>
     627                            <div class="title">
     628                                Users
     629                                <div class="description">
     630                                    Define who should get content alerts.
     631                                </div>
     632                            </div>
     633                            <div class="controls">
     634                                <?php $defUsers = get_option('expresscurate_content_alert_users', ''); ?>
     635                                <textarea class="expresscurate_displayNone" name="expresscurate_content_alert_users"
     636                                          id="expresscurate_content_alert_users" cols="30" rows="10">
     637                                <?php echo $defUsers; ?>
     638                            </textarea>
     639                                <ul class="usersToAlert defItems">
     640                                    <?php
     641                                    $users = explode(', ', $defUsers);
     642                                    if (!empty($users)) {
     643                                        foreach ($users as $user) {
     644                                            if (!empty($user)) {
     645                                                echo '<li>' . $user . '<span class="close"></span></li>';
     646                                            }
     647                                        }
     648                                    }
     649                                    ?>
     650                                </ul>
     651                                <div class="addUsers">
     652                                    <input type="text" placeholder="Add Users" class="expresscurate_disableInputStyle"/>
     653                                    <span class=""><span></span></span>
     654                                    <?php
     655                                    $blogusers = get_users();
     656
     657                                    foreach ($blogusers as $user) {
     658                                        if ($user->roles[0] != 'subscriber') {
     659                                            $names[] = $user->user_login;
     660                                        }
     661                                    }
     662                                    $allUsers = implode(',', $names);
     663                                    if (!empty($allUsers)) {
     664                                        echo '<textarea class="expresscurate_displayNone" name=""
     665                                      id="expresscurate_allUsers" value="' . $allUsers . '" >' . $allUsers . '</textarea>';
     666                                    }
     667                                    ?>
     668                                </div>
     669                            </div>
     670                        </li>
     671                    </div>
     672
    584673                </ul>
    585674                <div class="centerSave">
  • expresscurate/trunk/templates/sitemap.php

    r1162493 r1179063  
    169169        $blogName = urlencode(urlencode(get_bloginfo('url')));
    170170        ?>
    171             <a class="getApiKey  <?php if (strlen(get_option('expresscurate_google_refresh_token')) > 2) {echo 'expresscurate_displayNone';}?>" href="https://www.expresscurate.com/api/connector/google/webmasters/refreshtoken/<?=$blogName?>">Authorize access to Google Webmaster Tools</a>
     171            <a class="getApiKey  <?php if (strlen(get_option('expresscurate_google_refresh_token')) > 2) {echo 'expresscurate_displayNone';}?>" href="https://www.expresscurate.com/api/connector/google/webmasters/refreshtoken/<?=$blogName?>">Authorize access to Google Search Console (aka Webmaster Tools)</a>
    172172    </div>
    173173</li>
  • expresscurate/trunk/templates/social_posts_widget.php

    r1172885 r1179063  
    1111$publishedPosts = get_post_meta($post->ID, '_expresscurate_social_published_post_messages', true);
    1212$posts = get_post_meta($post->ID, '_expresscurate_social_post_messages', true);
    13 $postLength = 110;
    1413?>
    1514<div class="expresscurate_social_post_widget">
     
    1716
    1817    <input type="hidden" id="expresscurate_social_post_messages" name="expresscurate_social_post_messages"
    19            value="<?php echo htmlspecialchars(json_encode($posts),ENT_QUOTES); ?>"/>
     18           value="<?php echo htmlspecialchars(json_encode($posts), ENT_QUOTES); ?>"/>
    2019
    2120
     
    3736    if (!empty($posts)) {
    3837        foreach ($posts as $i => $data) {
    39             $postLengthCount = $postLength - strlen($data['message']);
    40             $approved=$data['approved'];?>
     38            $postLengthCount = ($data['postLength']);
     39            $approved = $data['approved']; ?>
    4140            <div class="expresscurate_socialPostBlock" id="<?php echo $data['id']; ?>">
    4241                <ul class="topControls">
    4342
    4443                    <?php if (!empty($profiles)) { ?>
    45                         <select name="profile" id="profile" <?php if($approved) echo 'disabled="disabled"' ?> >
     44                        <select name="profile" id="profile" <?php if ($approved) echo 'disabled="disabled"' ?> >
    4645                            <?php
    4746                            foreach ($profiles as $profile) {
     
    5352                                        echo 'selected="selected"';
    5453                                    }
    55                                     ?> value="<?php echo $profileId; ?>"><?php echo $profile->formatted_service; ?> / <?php echo $profile->formatted_username; ?></option>
     54                                    ?> value="<?php echo $profileId; ?>"><?php echo $profile->formatted_service; ?>
     55                                        / <?php echo $profile->formatted_username; ?></option>
    5656                                <?php }
    5757                            } ?>
     
    5959                    <?php } ?>
    6060
    61                     <li class="close expresscurate_floatRight <?php if($approved) echo 'expresscurate_displayNone' ?> "></li>
     61                    <li class="close expresscurate_floatRight <?php if ($approved) echo 'expresscurate_displayNone' ?> "></li>
    6262                    <div class="expresscurate_clear"></div>
    6363                </ul>
    64                 <textarea name="" class="expresscurate_social_post_content expresscurate_disableInputStyle" <?php if($approved) echo 'readonly="readonly"' ?>
     64                <textarea name=""
     65                          class="expresscurate_social_post_content expresscurate_disableInputStyle" <?php if ($approved) echo 'readonly="readonly"' ?>
    6566                          id=""><?php echo $data['message']; ?></textarea>
    6667                <ul class="bottomControls">
    67                     <li class="expresscurate_social_widget_buttons expresscurate_floatRight <?php if($approved) echo 'expresscurate_displayNone' ?> approve">Approve</li>
    68                     <li class="expresscurate_social_widget_buttons expresscurate_floatRight <?php if($approved) echo 'expresscurate_displayNone' ?> clone">Copy</li>
    69                     <li class="expresscurate_socialPostLength <?php if($approved) echo 'expresscurate_displayNone' ?> expresscurate_floatRight <?php if ($postLengthCount < 0) echo 'error'; ?>"><?php echo $postLengthCount; ?></li>
    70                     <li class="expresscurate_social_widget_buttons <?php if(!$approved) echo 'expresscurate_displayNone' ?> edit">Edit</li>
     68                    <li class="expresscurate_social_widget_buttons expresscurate_floatRight <?php if ($approved) echo 'expresscurate_displayNone' ?> approve">
     69                        Approve
     70                    </li>
     71                    <li class="expresscurate_social_widget_buttons expresscurate_floatRight <?php if ($approved) echo 'expresscurate_displayNone' ?> clone">
     72                        Copy
     73                    </li>
     74                    <li class="expresscurate_socialPostLength <?php if ($approved) echo 'expresscurate_displayNone' ?> expresscurate_floatRight <?php if ($postLengthCount < 0) echo 'error'; ?>"><?php echo $postLengthCount; ?></li>
     75                    <li class="expresscurate_social_widget_buttons <?php if (!$approved) echo 'expresscurate_displayNone' ?> edit">
     76                        Edit
     77                    </li>
    7178                    <div class="expresscurate_clear"></div>
    7279                </ul>
     
    103110                        if ($profilesStatus->$profileId == 'on' || empty($profilesStatus->$profileId)) {
    104111                            ?>
    105                             <option value="<?php echo $profileId; ?>"><?php echo $profile->formatted_service; ?> / <?php echo $profile->formatted_username; ?></option>
     112                            <option value="<?php echo $profileId; ?>"><?php echo $profile->formatted_service; ?>
     113                                / <?php echo $profile->formatted_username; ?></option>
    106114                        <?php }
    107115                    } ?>
Note: See TracChangeset for help on using the changeset viewer.