public static function comment_edited($commentID = 0, $postID = 0)
 {
     //Clear the comment cache
     if (function_exists('clean_comment_cache')) {
         clean_comment_cache($commentID);
     }
     //For WP Cache and WP Super Cache
     if (function_exists('wp_cache_post_change')) {
         @wp_cache_post_change($postID);
     }
     //Get out if user is admin or post owner
     if (AECCore::is_comment_owner($postID)) {
         return;
     }
     //Increment the number of edited comments
     AECCore::increment_edit_count();
 }
Esempio n. 2
0
 /**
  * Clear something from the cache.
  *
  * @synopsis [--post_id=<post-id>] [--permalink=<permalink>]
  */
 function flush($args = array(), $assoc_args = array())
 {
     if (isset($assoc_args['post_id'])) {
         if (is_numeric($assoc_args['post_id'])) {
             wp_cache_post_change($assoc_args['post_id']);
         } else {
             WP_CLI::error('This is not a valid post id.');
         }
         wp_cache_post_change($assoc_args['post_id']);
     } elseif (isset($assoc_args['permalink'])) {
         $id = url_to_postid($assoc_args['permalink']);
         if (is_numeric($id)) {
             wp_cache_post_change($id);
         } else {
             WP_CLI::error('There is no post with this permalink.');
         }
     } else {
         global $file_prefix;
         wp_cache_clean_cache($file_prefix, true);
         WP_CLI::success('Cache cleared.');
     }
 }
Esempio n. 3
0
 /**
  * Clear something from the cache
  *
  * @param array $args
  * @param array $vars
  */
 function flush($args = array(), $vars = array())
 {
     if (function_exists('wp_cache_clear_cache')) {
         if (isset($vars['post_id'])) {
             if (is_numeric($vars['post_id'])) {
                 wp_cache_post_change($vars['post_id']);
             } else {
                 WP_CLI::error('This is not a valid post id.');
             }
             wp_cache_post_change($vars['post_id']);
         } elseif (isset($vars['permalink'])) {
             $id = url_to_postid($vars['permalink']);
             if (is_numeric($id)) {
                 wp_cache_post_change($id);
             } else {
                 WP_CLI::error('There is no post with this permalink.');
             }
         } else {
             wp_cache_clear_cache();
         }
     } else {
         WP_CLI::error('The WP Super Cache could not be found, is it installed?');
     }
 }
 /**
  * Tell caching plugins to clear their caches related to a post
  *
  * @static
  * @param int $post_id
  */
 public static function clear_post_cache($post_id)
 {
     if (function_exists('wp_cache_post_change')) {
         // WP Super Cache
         $GLOBALS['super_cache_enabled'] = 1;
         wp_cache_post_change($post_id);
     } elseif (function_exists('w3tc_pgcache_flush_post')) {
         // W3 Total Cache
         w3tc_pgcache_flush_post($post_id);
     }
 }
Esempio n. 5
0
/**
 * Save composer code
 *
 * @since 1.2.4
 */
function dslc_ajax_save_draft_composer($atts)
{
    // Allowed to do this?
    if (is_user_logged_in() && current_user_can(DS_LIVE_COMPOSER_CAPABILITY_SAVE)) {
        // The array we'll pass back to the AJAX call
        $response = array();
        // The composer code
        $composer_code = $_POST['dslc_code'];
        // The ID of the post/page
        $post_id = $_POST['dslc_post_id'];
        // Add/update the post/page with the composer code
        if (update_post_meta($post_id, 'dslc_code_draft', $composer_code)) {
            $response['status'] = 'success';
        } else {
            $response['status'] = 'failed';
        }
        // Encode response
        $response_json = json_encode($response);
        // Send the response
        header("Content-Type: application/json");
        echo $response_json;
        // Refresh cache
        if (function_exists('wp_cache_post_change')) {
            $GLOBALS['super_cache_enabled'] = 1;
            wp_cache_post_change($post_id);
        }
        // Au revoir
        exit;
    }
}
Esempio n. 6
0
<?php

// this script can be used to synchronize posts to Discourse
// there appears to be bugs in publish_future_post
// see: http://wordpress.org/support/topic/is-publish_future_post-hook-still-present-working
require_once "../wp-load.php";
$discourse = new Discourse();
$args = array('numberposts' => '3', 'orderby' => 'date', 'post_type' => array('post'));
$last_posts = get_posts($args);
foreach ($last_posts as $post) {
    setup_postdata($post);
    $link = get_post_meta($post->ID, 'discourse_permalink', true);
    if (!$link) {
        $pub = get_post_meta($post->ID, 'publish_to_discourse', true);
        if ($pub) {
            $discourse::sync_to_discourse($post->ID, $post->post_title, $post->post_content);
            wp_cache_post_change($post->ID);
        }
    }
}
function wp_cache_get_postid_from_comment($comment_id)
{
    $comment = get_commentdata($comment_id, 1, true);
    $postid = $comment['comment_post_ID'];
    // We must check it up again due to WP bugs calling two different actions
    // for delete, for example both wp_set_comment_status and delete_comment
    // are called whene deleting a comment
    if ($postid > 0) {
        return wp_cache_post_change($postid);
    } else {
        return wp_cache_post_change(wp_cache_post_id());
    }
}
Esempio n. 8
0
    function ajax()
    {
        $award_id = intval($_POST['award_id']);
        $award = get_post($award_id);
        if (is_null($award) || $award->post_type != $this->get_post_type_name()) {
            die;
        }
        $admin_email = get_settings('admin_email');
        header('Content-Type: text/html');
        # Only actions are valid on awards that haven't been accepted or
        # rejected yet
        $award_status = get_post_meta($award_id, 'wpbadger-award-status', true);
        if ($award_status != 'Awarded') {
            ?>
            <div class="wpbadger-award-error">
                <p>This award has already been claimed.</p>
                <p>If you believe this was done in error, please contact the 
                <a href="mailto:<?php 
            esc_attr_e($admin_email);
            ?>
">site administrator</a>.</p>
            </div>
            <?php 
            die;
        }
        switch ($_POST['award_action']) {
            case 'accept':
                update_post_meta($award_id, 'wpbadger-award-status', 'Accepted');
                // If WP Super Cache Plugin installed, delete cache files for award post
                if (function_exists('wp_cache_post_change')) {
                    wp_cache_post_change($award_id);
                }
                ?>
            <div class="wpbadger-award-updated">
                <p>You have successfully accepted to add your award to your backpack.</p>
            </div>
            <?php 
                break;
            case 'reject':
                update_post_meta($award_id, 'wpbadger-award-status', 'Rejected');
                // If WP Super Cache Plugin installed, delete cache files for award post
                if (function_exists('wp_cache_post_change')) {
                    wp_cache_post_change($award_id);
                }
                ?>
            <div class="wpbadger-award-updated">
                <p>You have successfully declined to add your award to your backpack.</p>
            </div>
            <?php 
                break;
        }
        die;
    }
function wp_cache_get_postid_from_comment($comment_id)
{
    $comment = get_commentdata($comment_id, 1, true);
    $postid = $comment['comment_post_ID'];
    // Do nothing if comment is not moderated
    // http://ocaoimh.ie/2006/12/05/caching-wordpress-with-wp-cache-in-a-spam-filled-world
    if (!preg_match('/wp-admin\\//', $_SERVER['REQUEST_URI']) && $comment['comment_approved'] != 1) {
        return $post_id;
    }
    // We must check it up again due to WP bugs calling two different actions
    // for delete, for example both wp_set_comment_status and delete_comment
    // are called when deleting a comment
    if ($postid > 0) {
        return wp_cache_post_change($postid);
    } else {
        return wp_cache_post_change(wp_cache_post_id());
    }
}
Esempio n. 10
0
 function widget($args, $instance)
 {
     extract($args);
     $title = apply_filters('widget_title', $instance['title']);
     $items = intval($instance['items']);
     //process expired news
     $tzone = get_option('timezone_string');
     date_default_timezone_set($tzone);
     $tdate = date('Ymd');
     $oldnews = query_posts(array('post_type' => 'news-update', 'meta_query' => array(array('key' => 'news_update_expiry_date', 'value' => $tdate, 'compare' => '<='))));
     if (count($oldnews) > 0) {
         foreach ($oldnews as $old) {
             if ($tdate == date('Ymd', strtotime(get_post_meta($old->ID, 'news_update_expiry_date', true)))) {
                 // if expiry today, check the time
                 if (date('H:i:s', strtotime(get_post_meta($old->ID, 'news_update_expiry_time', true))) > date('H:i:s')) {
                     continue;
                 }
             }
             $expiryaction = get_post_meta($old->ID, 'news_update_expiry_action', true);
             if ($expiryaction == 'Revert to draft status') {
                 $my_post = array();
                 $my_post['ID'] = $old->ID;
                 $my_post['post_status'] = 'draft';
                 wp_update_post($my_post);
                 delete_post_meta($old->ID, 'news_update_expiry_date');
                 delete_post_meta($old->ID, 'news_update_expiry_time');
                 delete_post_meta($old->ID, 'news_update_expiry_action');
                 delete_post_meta($old->ID, 'news_auto_expiry');
                 if (function_exists('wp_cache_post_change')) {
                     wp_cache_post_change($old->ID);
                 }
                 if (function_exists('wp_cache_post_change')) {
                     wp_cache_post_change($my_post);
                 }
             }
             if ($expiryaction == 'Move to trash') {
                 $my_post = array();
                 $my_post['ID'] = $old->ID;
                 $my_post['post_status'] = 'trash';
                 delete_post_meta($old->ID, 'news_update_expiry_date');
                 delete_post_meta($old->ID, 'news_update_expiry_time');
                 delete_post_meta($old->ID, 'news_update_expiry_action');
                 delete_post_meta($old->ID, 'news_auto_expiry');
                 wp_update_post($my_post);
                 if (function_exists('wp_cache_post_change')) {
                     wp_cache_post_change($old->ID);
                 }
                 if (function_exists('wp_cache_post_change')) {
                     wp_cache_post_change($my_post);
                 }
             }
         }
         wp_reset_query();
     }
     //display need to know stories
     $acf_key = "widget_" . $this->id_base . "-" . $this->number . "_news_update_widget_include_type";
     $news_update_types = get_option($acf_key);
     if ($icon == '') {
         $icon = get_option('options_need_to_know_icon');
     }
     if ($icon == '') {
         $icon = "flag";
     }
     $acf_key = "widget_" . $this->id_base . "-" . $this->number . "_news_update_background_colour";
     $background_colour = get_option($acf_key);
     $acf_key = "widget_" . $this->id_base . "-" . $this->number . "_news_update_text_colour";
     $text_colour = get_option($acf_key);
     $acf_key = "widget_" . $this->id_base . "-" . $this->number . "_news_update_border_colour";
     $border_colour = get_option($acf_key);
     $border_height = get_option('options_widget_border_height', '5');
     if (!$news_update_types || $news_update_types == "None") {
         $cquery = array('orderby' => 'post_date', 'order' => 'DESC', 'post_type' => 'news-update', 'posts_per_page' => $items);
     } else {
         $cquery = array('orderby' => 'post_date', 'order' => 'DESC', 'post_type' => 'news-update', 'posts_per_page' => $items, 'tax_query' => array(array('taxonomy' => 'news-update-type', 'field' => 'id', 'terms' => $news_update_types)));
     }
     $news = new WP_Query($cquery);
     if ($news->post_count != 0) {
         echo "<style>";
         if ($border_colour) {
             echo ".need-to-know-container." . sanitize_file_name($title) . " { background-color: " . $background_colour . "; color: " . $text_colour . "; padding: 1em; margin-top: 16px; border-top: " . $border_height . "px solid " . $border_colour . " ; }\n";
         } else {
             echo ".need-to-know-container." . sanitize_file_name($title) . " { background-color: " . $background_colour . "; color: " . $text_colour . "; padding: 1em; margin-top: 16px; border-top: 5px solid rgba(0, 0, 0, 0.45); }\n";
         }
         echo ".need-to-know-container." . sanitize_file_name($title) . " a { color: " . $text_colour . "; }\n";
         echo ".need-to-know-container." . sanitize_file_name($title) . " .category-block { background: " . $background_colour . "; }\n";
         echo ".need-to-know-container." . sanitize_file_name($title) . " .category-block h3 { padding: 0 0 10px 0; margin-top: 0; border: none ; color: " . $text_colour . "; }\n";
         echo ".need-to-know-container." . sanitize_file_name($title) . " .category-block ul li { border-top: 1px solid rgba(255, 255, 255, 0.45); }\n";
         echo ".need-to-know-container." . sanitize_file_name($title) . " .category-block p.more-updates { margin-bottom: 0 !important; margin-top: 10px; font-weight: bold; }\n";
         echo "</style>";
         if ($title) {
             echo "<div class='need-to-know-container " . sanitize_file_name($title) . "'>";
             echo $before_widget;
             echo $before_title . $title . $after_title;
         }
         echo "\n\t\t\t<div class='need-to-know'>\n\t\t\t<ul class='need'>";
     }
     $k = 0;
     $alreadydone = array();
     while ($news->have_posts()) {
         $news->the_post();
         if (in_array($post->ID, $alreadydone)) {
             //don't show if already in stickies
             continue;
         }
         $k++;
         if ($k > $items) {
             break;
         }
         $thistitle = get_the_title($post->ID);
         $thisURL = get_permalink($post->ID);
         $display_types = '';
         $display_types = array();
         $types_array = get_the_terms($post->ID, 'news-update-type');
         if ($types_array) {
             foreach ($types_array as $t) {
                 $display_types[] = $t->name;
                 $icon = get_option('news-update-type_' . $t->term_id . '_news_update_icon');
                 if ($icon == '') {
                     $icon = get_option('options_need_to_know_icon');
                 }
                 if ($icon == '') {
                     $icon = "flag";
                 }
                 $display_types = implode(", ", $display_types) . "";
             }
         }
         echo "<li><a href='{$thisURL}' title='" . $display_types . " update'><span class='glyphicon glyphicon-" . $icon . "'></span> " . $thistitle . "</a></li>";
     }
     if ($news->post_count != 0) {
         echo "</ul></div>";
         if ($news_update_types) {
             $landingpage = get_term_link($types_array[0]->term_id, 'news-update-type');
             echo '<p class="more-updates"><a title="' . $landingpage_link_text . '" class="small" href="' . $landingpage . '">' . $title . '</a> <span class="dashicons dashicons-arrow-right-alt2"></span></p>';
         } else {
             $landingpage = get_option('options_module_news_update_page');
             if (!$landingpage) {
                 $landingpage_link_text = $title;
                 $landingpage = site_url() . '/news-update/';
             } else {
                 $landingpage_link_text = get_the_title($landingpage[0]);
                 $landingpage = get_permalink($landingpage[0]);
             }
             echo '<p class="more-updates"><a title="' . $landingpage_link_text . '" class="small" href="' . $landingpage . '">' . $landingpage_link_text . '</a> <span class="dashicons dashicons-arrow-right-alt2"></span></p>';
         }
         echo "<div class='clearfix'></div>";
         echo $after_widget;
         echo "</div>";
     }
     wp_reset_query();
 }
Esempio n. 11
0
 function cleanCache($posts = array())
 {
     if (!defined('WP_CACHE')) {
         return;
     }
     if (count($posts) > 0) {
         //check wp-cache
         @(include_once ABSPATH . 'wp-content/plugins/wp-cache/wp-cache.php');
         if (function_exists('wp_cache_post_change')) {
             foreach ($posts as $post_id) {
                 wp_cache_post_change($post_id);
             }
         } else {
             //check wp-super-cache
             @(include_once ABSPATH . 'wp-content/plugins/wp-super-cache/wp-cache.php');
             if (function_exists('wp_cache_post_change')) {
                 foreach ($posts as $post_id) {
                     wp_cache_post_change($post_id);
                 }
             }
         }
     }
 }
Esempio n. 12
0
function wp_cache_post_edit($post_id)
{
    global $wp_cache_clear_on_post_edit, $cache_path, $blog_cache_dir, $wp_cache_object_cache;
    static $last_post_edited = -1;
    if ($post_id == $last_post_edited) {
        wp_cache_debug("wp_cache_post_edit: Already processed post {$post_id}.", 4);
        return $post_id;
    }
    $post = get_post($post_id);
    if (is_object($post) == false) {
        return $post_id;
    }
    // Some users are inexplicibly seeing this error on scheduled posts.
    // define this constant to disable the post status check.
    if (false == defined('WPSCFORCEUPDATE') && $post->post_status != 'publish') {
        wp_cache_debug("wp_cache_post_edit: draft post, not deleting any cache files.", 4);
        return $post_id;
    }
    // we want to process the post again just in case it becomes published before the second time this function is called.
    $last_post_edited = $post_id;
    if ($wp_cache_clear_on_post_edit) {
        wp_cache_debug("wp_cache_post_edit: Clearing cache {$blog_cache_dir} and {$cache_path}supercache/ on post edit per config.", 2);
        if ($wp_cache_object_cache) {
            reset_oc_version();
        } else {
            prune_super_cache($blog_cache_dir, true);
            prune_super_cache(get_supercache_dir(), true);
        }
    } else {
        wp_cache_debug("wp_cache_post_edit: Clearing cache for post {$post_id} on post edit.", 2);
        wp_cache_post_change($post_id);
    }
}
Esempio n. 13
0
 /**
  * 
  * @since 1.4
  * @return string
  */
 public function &rebuildHTML5Sitemap()
 {
     include $this->dirPath . '/core/sitetree-factory.class.php';
     include $this->dirPath . '/core/sitetree-html5-factory.class.php';
     $page_id = (int) $this->db->getOption('page_for_sitemap');
     // We don't use 'wp_update_post' because it would generate a new revision.
     global $wpdb;
     $query_str = $wpdb->prepare("UPDATE {$wpdb->posts} SET `post_modified` = %s, `post_modified_gmt` = %s WHERE `ID` = %d", current_time('mysql'), current_time('mysql', 1), $page_id);
     $wpdb->query($query_str);
     $factory = new SiteTreeHTML5Factory($this->db);
     $sitemap = $factory->getSitemap();
     $this->db->setOption('stats_html5', $factory->getStats());
     $this->db->setCache('html5', $sitemap);
     // Try to force WP Super Cache to flush the cached version of the page where the html5 sitemap is shown
     if (WP_CACHE && function_exists('wp_cache_post_change')) {
         if ($page_id !== 0) {
             global $super_cache_enabled;
             $super_cache_enabled = 1;
             wp_cache_post_change($page_id);
         }
     }
     return $sitemap;
 }
Esempio n. 14
0
 public function clear_post_cache($post_id)
 {
     switch (get_post_status($post_id)) {
         case 'draft':
         case 'pending':
         case 'future':
         case 'private':
         case 'publish':
             $lca = $this->p->cf['lca'];
             $lang = SucomUtil::get_locale();
             $permalink = get_permalink($post_id);
             $permalink_no_meta = add_query_arg(array('WPSSO_META_TAGS_DISABLE' => 1), $permalink);
             $sharing_url = $this->p->util->get_sharing_url($post_id);
             $transients = array('SucomCache::get' => array('url:' . $permalink, 'url:' . $permalink_no_meta), 'WpssoHead::get_header_array' => array('lang:' . $lang . '_post:' . $post_id . '_url:' . $sharing_url, 'lang:' . $lang . '_post:' . $post_id . '_url:' . $sharing_url . '_crawler:pinterest'), 'WpssoMeta::get_mod_column_content' => array('mod:post_lang:' . $lang . '_id:' . $post_id . '_column:' . $lca . '_og_image'));
             $transients = apply_filters($lca . '_post_cache_transients', $transients, $post_id, $lang, $sharing_url);
             $objects = array('SucomWebpage::get_content' => array('lang:' . $lang . '_post:' . $post_id . '_filtered', 'lang:' . $lang . '_post:' . $post_id . '_unfiltered'), 'SucomWebpage::get_hashtags' => array('lang:' . $lang . '_post:' . $post_id));
             $objects = apply_filters($lca . '_post_cache_objects', $objects, $post_id, $lang, $sharing_url);
             $deleted = $this->clear_cache_objects($transients, $objects);
             if (!empty($this->p->options['plugin_cache_info']) && $deleted > 0) {
                 $this->p->notice->inf($deleted . ' items removed from the WordPress object and transient caches.', true);
             }
             if (function_exists('w3tc_pgcache_flush_post')) {
                 // w3 total cache
                 w3tc_pgcache_flush_post($post_id);
             }
             if (function_exists('wp_cache_post_change')) {
                 // wp super cache
                 wp_cache_post_change($post_id);
             }
             break;
     }
 }
Esempio n. 15
0
function wp_cache_post_edit($post_id)
{
    global $wp_cache_clear_on_post_edit, $cache_path;
    if ($wp_cache_clear_on_post_edit) {
        prune_super_cache($cache_path, true);
    } else {
        wp_cache_post_change($post_id);
    }
}
Esempio n. 16
0
                     wp_cache_post_change($old->ID);
                 }
             }
             if ($expiryaction == 'Move to trash') {
                 $my_post = array();
                 $my_post['ID'] = $old->ID;
                 $my_post['post_status'] = 'trash';
                 delete_post_meta($old->ID, 'expiry_date');
                 delete_post_meta($old->ID, 'expiry_time');
                 delete_post_meta($old->ID, 'expiry_action');
                 wp_update_post($my_post);
                 if (function_exists('wp_cache_post_change')) {
                     wp_cache_post_change($old->ID);
                 }
                 if (function_exists('wp_cache_post_change')) {
                     wp_cache_post_change($my_post);
                 }
             }
         }
     }
     $timer = array();
     $timer[] = 'last_removed';
     $gi = "general_intranet_expired_news_cache";
     $expirednewscache = get_option($gi);
     if ($expirednewscache <= 0) {
         $expirednewscache = 60 * 8;
     }
     set_transient('cached_removenews', $timer, 60 * $expirednewscache);
     // customised cache period
     wp_reset_query();
 }
Esempio n. 17
0
function jm_post_like()
{
    $nonce = $_POST['nonce'];
    if (!wp_verify_nonce($nonce, 'ajax-nonce')) {
        die('Nope!');
    }
    if (isset($_POST['jm_post_like'])) {
        $post_id = $_POST['post_id'];
        // post id
        $post_like_count = get_post_meta($post_id, "_post_like_count", true);
        // post like count
        if (function_exists('wp_cache_post_change')) {
            // invalidate WP Super Cache if exists
            $GLOBALS["super_cache_enabled"] = 1;
            wp_cache_post_change($post_id);
        }
        if (is_user_logged_in()) {
            // user is logged in
            $user_id = get_current_user_id();
            // current user
            $meta_POSTS = get_user_option("_liked_posts", $user_id);
            // post ids from user meta
            $meta_USERS = get_post_meta($post_id, "_user_liked");
            // user ids from post meta
            $liked_POSTS = NULL;
            // setup array variable
            $liked_USERS = NULL;
            // setup array variable
            if (count($meta_POSTS) != 0) {
                // meta exists, set up values
                $liked_POSTS = $meta_POSTS;
            }
            if (!is_array($liked_POSTS)) {
                // make array just in case
                $liked_POSTS = array();
            }
            if (count($meta_USERS) != 0) {
                // meta exists, set up values
                $liked_USERS = $meta_USERS[0];
            }
            if (!is_array($liked_USERS)) {
                // make array just in case
                $liked_USERS = array();
            }
            $liked_POSTS['post-' . $post_id] = $post_id;
            // Add post id to user meta array
            $liked_USERS['user-' . $user_id] = $user_id;
            // add user id to post meta array
            $user_likes = count($liked_POSTS);
            // count user likes
            if (!AlreadyLiked($post_id)) {
                // like the post
                update_post_meta($post_id, "_user_liked", $liked_USERS);
                // Add user ID to post meta
                update_post_meta($post_id, "_post_like_count", ++$post_like_count);
                // +1 count post meta
                update_user_option($user_id, "_liked_posts", $liked_POSTS);
                // Add post ID to user meta
                update_user_option($user_id, "_user_like_count", $user_likes);
                // +1 count user meta
                echo $post_like_count;
                // update count on front end
            } else {
                // unlike the post
                $pid_key = array_search($post_id, $liked_POSTS);
                // find the key
                $uid_key = array_search($user_id, $liked_USERS);
                // find the key
                unset($liked_POSTS[$pid_key]);
                // remove from array
                unset($liked_USERS[$uid_key]);
                // remove from array
                $user_likes = count($liked_POSTS);
                // recount user likes
                update_post_meta($post_id, "_user_liked", $liked_USERS);
                // Remove user ID from post meta
                update_post_meta($post_id, "_post_like_count", --$post_like_count);
                // -1 count post meta
                update_user_option($user_id, "_liked_posts", $liked_POSTS);
                // Remove post ID from user meta
                update_user_option($user_id, "_user_like_count", $user_likes);
                // -1 count user meta
                echo "already" . $post_like_count;
                // update count on front end
            }
        } else {
            // user is not logged in (anonymous)
            $ip = $_SERVER['REMOTE_ADDR'];
            // user IP address
            $meta_IPS = get_post_meta($post_id, "_user_IP");
            // stored IP addresses
            $liked_IPS = NULL;
            // set up array variable
            if (count($meta_IPS) != 0) {
                // meta exists, set up values
                $liked_IPS = $meta_IPS[0];
            }
            if (!is_array($liked_IPS)) {
                // make array just in case
                $liked_IPS = array();
            }
            if (!in_array($ip, $liked_IPS)) {
                // if IP not in array
                $liked_IPS['ip-' . $ip] = $ip;
            }
            // add IP to array
            if (!AlreadyLiked($post_id)) {
                // like the post
                update_post_meta($post_id, "_user_IP", $liked_IPS);
                // Add user IP to post meta
                update_post_meta($post_id, "_post_like_count", ++$post_like_count);
                // +1 count post meta
                echo $post_like_count;
                // update count on front end
            } else {
                // unlike the post
                $ip_key = array_search($ip, $liked_IPS);
                // find the key
                unset($liked_IPS[$ip_key]);
                // remove from array
                update_post_meta($post_id, "_user_IP", $liked_IPS);
                // Remove user IP from post meta
                update_post_meta($post_id, "_post_like_count", --$post_like_count);
                // -1 count post meta
                echo "already" . $post_like_count;
                // update count on front end
            }
        }
    }
    exit;
}
Esempio n. 18
0
function wp_cache_post_edit($post_id)
{
    global $wp_cache_clear_on_post_edit, $cache_path, $blog_cache_dir;
    if ($wp_cache_clear_on_post_edit) {
        if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
            wp_cache_debug("Clearing cache {$blog_cache_dir} and {$cache_path}supercache/ on post edit per config.", 2);
        }
        prune_super_cache($blog_cache_dir, true);
        prune_super_cache($cache_path . 'supercache/', true);
    } else {
        if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
            wp_cache_debug("Clearing cache for post {$post_id} on post edit.", 2);
        }
        wp_cache_post_change($post_id);
    }
}
Esempio n. 19
0
function wp_cache_post_edit($post_id)
{
    global $wp_cache_clear_on_post_edit, $cache_path, $blog_cache_dir;
    static $last_post_edited = -1;
    if ($post_id == $last_post_edited) {
        return $post_id;
    }
    $last_post_edited = $post_id;
    $post = get_post($post_id);
    if ($post->post_status != 'publish') {
        if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
            wp_cache_debug("wp_cache_post_edit: draft post, not deleting any cache files.", 4);
        }
        return $post_id;
    }
    if ($wp_cache_clear_on_post_edit) {
        if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
            wp_cache_debug("Clearing cache {$blog_cache_dir} and {$cache_path}supercache/ on post edit per config.", 2);
        }
        if ($wp_cache_object_cache) {
            reset_oc_version();
        } else {
            prune_super_cache($blog_cache_dir, true);
            prune_super_cache(get_supercache_dir(), true);
        }
    } else {
        if (isset($GLOBALS['wp_super_cache_debug']) && $GLOBALS['wp_super_cache_debug']) {
            wp_cache_debug("Clearing cache for post {$post_id} on post edit.", 2);
        }
        wp_cache_post_change($post_id);
    }
}
function yasr_wp_super_cache_support($post_id)
{
    if (function_exists('wp_cache_post_change')) {
        wp_cache_post_change($post_id);
    }
}
function wp_cache_post_edit($post_id)
{
    global $wp_cache_clear_on_post_edit, $cache_path, $blog_cache_dir;
    if ($wp_cache_clear_on_post_edit) {
        prune_super_cache($blog_cache_dir, true);
        prune_super_cache($cache_path . 'supercache/', true);
    } else {
        wp_cache_post_change($post_id);
    }
}
Esempio n. 22
0
 function widget($args, $instance)
 {
     extract($args);
     $title = apply_filters('widget_title', $instance['title']);
     $largeitems = intval($instance['largeitems']);
     $mediumitems = intval($instance['mediumitems']);
     $thumbnailitems = intval($instance['thumbnailitems']);
     $listitems = intval($instance['listitems']);
     $showexcerpt = $instance['showexcerpt'];
     $acf_key = "widget_" . $this->id_base . "-" . $this->number . "_pin_stories";
     $top_slot = get_option($acf_key);
     $acf_key = "widget_" . $this->id_base . "-" . $this->number . "_exclude_stories";
     $exclude = get_option($acf_key);
     global $post;
     $removenews = get_transient('cached_removenews');
     if (!$removenews || !is_array($removenews)) {
         //process expired news
         $tzone = get_option('timezone_string');
         date_default_timezone_set($tzone);
         $tdate = date('Ymd');
         $oldnews = query_posts(array('post_type' => 'news', 'meta_query' => array(array('key' => 'news_expiry_date', 'value' => $tdate, 'compare' => '<='))));
         if (count($oldnews) > 0) {
             foreach ($oldnews as $old) {
                 if ($tdate == date('Ymd', strtotime(get_post_meta($old->ID, 'news_expiry_date', true)))) {
                     // if expiry today, check the time
                     if (date('H:i:s', strtotime(get_post_meta($old->ID, 'news_expiry_time', true))) > date('H:i:s')) {
                         continue;
                     }
                 }
                 $expiryaction = get_post_meta($old->ID, 'news_expiry_action', true);
                 if ($expiryaction == 'Revert to draft status') {
                     $my_post = array();
                     $my_post['ID'] = $old->ID;
                     $my_post['post_status'] = 'draft';
                     wp_update_post($my_post);
                     delete_post_meta($old->ID, 'news_expiry_date');
                     delete_post_meta($old->ID, 'news_expiry_time');
                     delete_post_meta($old->ID, 'news_expiry_action');
                     delete_post_meta($old->ID, 'news_auto_expiry');
                     if (function_exists('wp_cache_post_change')) {
                         wp_cache_post_change($old->ID);
                     }
                     if (function_exists('wp_cache_post_change')) {
                         wp_cache_post_change($my_post);
                     }
                 }
                 if ($expiryaction == 'Change to regular news') {
                     set_post_format($old->ID, '');
                     delete_post_meta($old->ID, 'news_expiry_date');
                     delete_post_meta($old->ID, 'news_expiry_time');
                     delete_post_meta($old->ID, 'news_expiry_action');
                     delete_post_meta($old->ID, 'news_auto_expiry');
                     if (function_exists('wp_cache_post_change')) {
                         wp_cache_post_change($old->ID);
                     }
                 }
                 if ($expiryaction == 'Move to trash') {
                     $my_post = array();
                     $my_post['ID'] = $old->ID;
                     $my_post['post_status'] = 'trash';
                     delete_post_meta($old->ID, 'news_expiry_date');
                     delete_post_meta($old->ID, 'news_expiry_time');
                     delete_post_meta($old->ID, 'news_expiry_action');
                     delete_post_meta($old->ID, 'news_auto_expiry');
                     wp_update_post($my_post);
                     if (function_exists('wp_cache_post_change')) {
                         wp_cache_post_change($old->ID);
                     }
                     if (function_exists('wp_cache_post_change')) {
                         wp_cache_post_change($my_post);
                     }
                 }
             }
         }
         wp_reset_query();
     }
     echo $before_widget;
     if ($title) {
         echo $before_title;
         echo $title;
         echo $after_title;
     }
     echo '<div id="ht-feature-news">';
     //load manual sticky news stories
     //	$home = get_page_by_path('/home/',OBJECT,'page');
     //$top_slot =  get_post_meta($home->ID,'top_news_stories');
     //forumalate grid of news stories and formats
     $totalstories = $largeitems + $mediumitems + $thumbnailitems + $listitems;
     $newsgrid = array();
     for ($i = 1; $i <= $totalstories; $i++) {
         if ($i <= $largeitems) {
             $newsgrid[] = "L";
         } elseif ($i <= $largeitems + $mediumitems) {
             $newsgrid[] = "M";
         } elseif ($i <= $largeitems + $mediumitems + $thumbnailitems) {
             $newsgrid[] = "T";
         } elseif ($i <= $largeitems + $mediumitems + $thumbnailitems + $listitems) {
             $newsgrid[] = "Li";
         }
     }
     $siteurl = site_url();
     //manual override news stories
     //display sticky top news stories
     $num_top_slots = count($top_slot);
     $to_fill = $totalstories - $num_top_slots;
     $k = -1;
     $alreadydone = array();
     if ($num_top_slots > 0) {
         foreach ((array) $top_slot as $thisslot) {
             if (!$thisslot) {
                 continue;
             }
             $slot = get_post($thisslot);
             if ($slot->post_status != 'publish') {
                 continue;
             }
             $k++;
             $alreadydone[] = $slot->ID;
             if (function_exists('get_video_thumbnail')) {
                 $videostill = get_video_thumbnail($slot->ID);
             }
             $thistitle = $slot->post_title;
             $thisURL = get_permalink($slot->ID);
             $video = 0;
             if (has_post_format('video', $slot->ID)) {
                 $video = apply_filters('the_content', get_post_meta($slot->ID, 'news_video_url', true));
             }
             if ($newsgrid[$k] == "L") {
                 $image_uri = wp_get_attachment_image_src(get_post_thumbnail_id($slot->ID), 'newshead');
                 if ($video) {
                     echo $video;
                 } elseif ($image_uri != "") {
                     echo "<a href='{$thisURL}'><img class='img img-responsive' src='{$image_uri[0]}' width='{$image_uri[1]}' height='{$image_uri[2]}' alt='" . govintranetpress_custom_title($slot->post_title) . "' /></a>";
                 }
             }
             if ($newsgrid[$k] == "M") {
                 $image_uri = wp_get_attachment_image_src(get_post_thumbnail_id($slot->ID), 'newsmedium');
                 if ($image_uri != "") {
                     echo "<a href='{$thisURL}'><img class='img img-responsive' src='{$image_uri[0]}' width='{$image_uri[1]}' height='{$image_uri[2]}' alt='" . govintranetpress_custom_title($slot->post_title) . "' /></a>";
                 }
             }
             if ($newsgrid[$k] == "T") {
                 $image_uri = "<a class='pull-right' href='" . $thisURL . "'>" . get_the_post_thumbnail($slot->ID, 'thumbnail', array('class' => 'media-object hidden-xs')) . "</a>";
                 if ($image_uri != "") {
                     $image_url = $image_uri;
                 }
             }
             $thisdate = $slot->post_date;
             $post = get_post($slot->ID);
             setup_postdata($post);
             $thisexcerpt = get_the_excerpt();
             $thisdate = date("j M Y", strtotime($thisdate));
             $ext_icon = '';
             if (get_post_format($slot->ID) == 'link') {
                 $ext_icon = "<span class='dashicons dashicons-migrate'></span> ";
             }
             if ($newsgrid[$k] == "T") {
                 echo "<div class='media'>" . $image_url;
             }
             echo "<div class='media-body'>";
             echo "<h3 class='noborder'>" . $ext_icon . "<a href='" . $thisURL . "'>" . $thistitle . "</a>" . $ext_icon . "</h3>";
             if ($newsgrid[$k] == "Li") {
                 echo "<p>";
                 echo '<span class="listglyph">' . get_the_date("j M Y");
                 comments_number('', ' <span class="dashicons dashicons-admin-comments"></span> 1 comment', ' <span class="dashicons dashicons-admin-comments"></span> % comments');
                 echo '</span> ';
                 echo " <a class='more' href='{$thisURL}' title='{$thistitle}'>Full story <span class='dashicons dashicons-arrow-right-alt2'></span></a></span></p>";
             } else {
                 if ($showexcerpt == 'on') {
                     echo "<p>";
                     echo '<span class="listglyph">' . get_the_date("j M Y");
                     comments_number('', ' <span class="dashicons dashicons-admin-comments"></span> 1 comment', ' <span class="dashicons dashicons-admin-comments"></span> % comments');
                     echo '</span> ';
                     echo "</p>";
                     echo $thisexcerpt;
                     echo "<p class='news_date'><a class='more' href='{$thisURL}' title='{$thistitle}'>Full story <span class='dashicons dashicons-arrow-right-alt2'></span></a></p>";
                 } else {
                     echo "<p>";
                     echo '<span class="listglyph">' . get_the_date("j M Y");
                     comments_number('', ' <span class="dashicons dashicons-admin-comments"></span> 1 comment', ' <span class="dashicons dashicons-admin-comments"></span> % comments');
                     echo '</span> ';
                     echo " <a class='more' href='{$thisURL}' title='{$thistitle}'>Full story <span class='dashicons dashicons-arrow-right-alt2'></span></a></span></p>";
                 }
             }
             echo "</div>";
             if ($newsgrid[$k] == "T") {
                 echo "</div>";
             }
             echo "<hr class='light' />\n";
         }
     }
     //end of stickies
     //display remaining stories
     $cquery = array('post_type' => 'news', 'posts_per_page' => $totalstories, 'post__not_in' => $exclude, 'tax_query' => array(array('taxonomy' => 'post_format', 'field' => 'slug', 'terms' => array('post-format-status'), "operator" => "NOT IN")));
     $news = new WP_Query($cquery);
     if ($news->post_count == 0) {
         echo "Nothing to show.";
     }
     global $post;
     while ($news->have_posts()) {
         $news->the_post();
         $theid = get_the_id();
         if (in_array($theid, $alreadydone)) {
             //don't show if already in stickies
             continue;
         }
         $k++;
         if ($k >= $totalstories) {
             break;
         }
         $thistitle = get_the_title($theid);
         $thisURL = get_permalink($theid);
         $video = 0;
         if (has_post_format('video', $theid)) {
             $video = apply_filters('the_content', get_post_meta($theid, 'news_video_url', true));
         }
         if ($newsgrid[$k] == "L") {
             $image_uri = wp_get_attachment_image_src(get_post_thumbnail_id($theid), 'newshead');
             if ($video) {
                 echo $video;
             } elseif ($image_uri != "") {
                 echo "<a href='{$thisURL}'><img class='img img-responsive' src='{$image_uri[0]}' width='{$image_uri[1]}' height='{$image_uri[2]}' alt='" . govintranetpress_custom_title($post->post_title) . "' /></a>";
             }
         }
         if ($newsgrid[$k] == "M") {
             $image_uri = wp_get_attachment_image_src(get_post_thumbnail_id($theid), 'newsmedium');
             if ($image_uri != "") {
                 echo "<a href='{$thisURL}'><img class='img img-responsive' src='{$image_uri[0]}' width='{$image_uri[1]}' height='{$image_uri[2]}' alt='" . govintranetpress_custom_title($post->post_title) . "' /></a>";
             }
         }
         if ($newsgrid[$k] == "T") {
             $image_uri = "<a class='pull-right' href='{$thisURL}'>" . get_the_post_thumbnail($theid, 'thumbnail', array('class' => 'media-object hidden-xs')) . "</a>";
             if ($image_uri != "") {
                 $image_url = $image_uri;
             }
         }
         $thisdate = get_the_date("j M Y");
         $thisexcerpt = get_the_excerpt();
         $ext_icon = '';
         if ($newsgrid[$k] == "T") {
             echo "<div class='media'>" . $image_url;
         }
         echo "<div class='media-body feature-news-" . strtolower($newsgrid[$k]) . "'>";
         if (get_post_format($theid) == 'link') {
             $ext_icon = "<i class='dashicons dashicons-migrate'></i> ";
         }
         echo "<h3 class='noborder'><a href='" . $thisURL . "'>" . $thistitle . "</a> " . $ext_icon . "</h3>";
         if ($newsgrid[$k] == "Li") {
             echo "<p>";
             echo '<span class="listglyph">' . get_the_date("j M Y");
             comments_number('', ' <span class="dashicons dashicons-admin-comments"></span> 1 comment', ' <span class="dashicons dashicons-admin-comments"></span> % comments');
             echo '</span> ';
             echo "</p>";
         } else {
             if ($showexcerpt == 'on') {
                 echo "<p>";
                 echo '<span class="listglyph">' . get_the_date("j M Y");
                 comments_number('', ' <span class="dashicons dashicons-admin-comments"></span> 1 comment', ' <span class="dashicons dashicons-admin-comments"></span> % comments');
                 echo '</span> ';
                 echo "</p>";
                 echo $thisexcerpt;
                 echo "<p class='news_date'><a class='more' href='{$thisURL}' title='{$thistitle}'>Full story <span class='dashicons dashicons-arrow-right-alt2'></span></a></p>";
             } else {
                 echo "<p>";
                 echo '<span class="listglyph">' . get_the_date("j M Y");
                 comments_number('', ' <span class="dashicons dashicons-admin-comments"></span> 1 comment', ' <span class="dashicons dashicons-admin-comments"></span> % comments');
                 echo " <a class='more' href='{$thisURL}' title='{$thistitle}'>Full story <span class='dashicons dashicons-arrow-right-alt2'></span></a></span></p>";
             }
         }
         echo "</div>";
         if ($newsgrid[$k] == "T") {
             echo "</div>";
         }
         echo "<hr class='light' />\n";
     }
     wp_reset_query();
     $landingpage = get_option('options_module_news_page');
     if (!$landingpage) {
         $landingpage_link_text = 'news';
         $landingpage = site_url() . '/newspage/';
     } else {
         $landingpage_link_text = get_the_title($landingpage[0]);
         $landingpage = get_permalink($landingpage[0]);
     }
     echo '<p><strong><a title="' . $landingpage_link_text . '" class="small" href="' . $landingpage . '">' . $landingpage_link_text . '</a></strong> <span class="dashicons dashicons-arrow-right-alt2"></span></p>';
     echo "<div class='clearfix'></div>";
     echo "</div>";
     echo $after_widget;
 }
Esempio n. 23
0
//CHANGE CLOSED VACANCIES TO DRAFT STATUS
$oldvacs = query_posts(array('post_type' => 'vacancy', 'meta_query' => array(array('key' => 'vacancy_closing_date', 'value' => $sdate, 'compare' => '<='))));
if (count($oldvacs) > 0) {
    foreach ($oldvacs as $old) {
        if ($tdate == date('Ymd', strtotime(get_post_meta($old->ID, 'vacancy_closing_date', true)))) {
            // if expiry today, check the time
            if (date('H:i:s', strtotime(get_post_meta($old->ID, 'vacancy_closing_time', true))) > date('H:i:s')) {
                continue;
            }
        }
        $my_post = array();
        $my_post['ID'] = $old->ID;
        $my_post['post_status'] = 'draft';
        wp_update_post($my_post);
        if (function_exists('wp_cache_post_change')) {
            wp_cache_post_change($old->ID);
        }
    }
}
wp_reset_query();
if (have_posts()) {
    while (have_posts()) {
        the_post();
        ?>

	<div class="col-lg-8 col-md-8 white ">
		<div class="row">
			<div class='breadcrumbs'>
				<?php 
        if (function_exists('bcn_display') && !is_front_page()) {
            bcn_display();
 private function clear_cached()
 {
     // If wp_super_cache is used, clear cache for front_page so changes are displayed immediately
     if (function_exists('wp_cache_post_change')) {
         $front_page_id = get_option('page_on_front');
         $GLOBALS["super_cache_enabled"] = 1;
         wp_cache_post_change($front_page_id);
     }
     delete_transient('degrona15_candidate_transient');
     delete_transient('degrona15_candidate_contact_info_transient');
     delete_transient('degrona15_candidate_call_to_action_buttons_transient');
 }