Example #1
0
function sp_google_maps_shortcode_meta()
{
    global $post;
    ?>
	<p>
		<strong>
			<label for="map_shortcode"><?php 
    _e("ShortCode For This Map", 'sp_google_maps');
    ?>
</label>
		</strong>
	</p>
	<?php 
    if (get_post_status($post->ID) === "publish") {
        ?>
	<input type="text" id="map_shortcode" value='[SPGM id="<?php 
        echo $post->ID;
        ?>
"]' onclick="select();" />
	<br>
	<code><?php 
        _e('Copy and Paste This ShortCode To Use This Map', 'sp_google_maps');
        ?>
</code>
	<?php 
    } else {
        ?>
	<p><small><?php 
        _e('ShortCode will apear after first save.', 'sp_google_maps');
        ?>
</small></p>
	<?php 
    }
}
Example #2
0
/**
 * Drop-down Pages sanitization callback example.
 *
 * - Sanitization: dropdown-pages
 * - Control: dropdown-pages
 *
 * Sanitization callback for 'dropdown-pages' type controls. This callback sanitizes `$page_id`
 * as an absolute integer, and then validates that $input is the ID of a published page.
 *
 * @see absint() https://developer.wordpress.org/reference/functions/absint/
 * @see get_post_status() https://developer.wordpress.org/reference/functions/get_post_status/
 *
 * @param int $page Page ID.
 * @param WP_Customize_Setting $setting Setting instance.
 *
 * @return int|string Page ID if the page is published; otherwise, the setting default.
 */
function kamino_sanitize_dropdown_pages($page_id, $setting)
{
    // Ensure $input is an absolute integer.
    $page_id = absint($page_id);
    // If $page_id is an ID of a published page, return it; otherwise, return the default.
    return 'publish' == get_post_status($page_id) ? $page_id : $setting->default;
}
Example #3
0
function x_shortcode_toc_item($atts)
{
    extract(shortcode_atts(array('id' => '', 'class' => '', 'style' => '', 'title' => '', 'page' => ''), $atts, 'x_toc_item'));
    $id = $id != '' ? 'id="' . esc_attr($id) . '"' : '';
    $class = $class != '' ? 'x-toc-item ' . esc_attr($class) : 'x-toc-item';
    $style = $style != '' ? 'style="' . $style . '"' : '';
    $title = $title != '' ? $title : '';
    switch ($page) {
        case 0:
            $page = '';
            break;
        case 1:
            $page = '';
            break;
        default:
            $page = $page;
            if (get_post_status(get_the_ID()) == "draft") {
                $page = '&page=' . $page;
            } else {
                $page = get_the_ID() == get_option('page_on_front') ? 'page/' . $page . '/' : $page . '/';
            }
    }
    $link = esc_url(get_permalink());
    $output = "<li {$id} class=\"{$class}\" {$style}><a href=" . $link . $page . " title=\"Go to {$title}\">" . $title . '</a></li>';
    return $output;
}
 static function problogger_jumbotron()
 {
     global $post;
     if (!$post) {
         return false;
     }
     $show = get_post_meta($post->ID, '_problogger_meta_jumbotron_show_key', true);
     if ($show == '2') {
         return false;
     }
     $the_post_id = get_post_meta($post->ID, '_problogger_meta_jumbotron_post_id', true);
     if (!get_post_status($the_post_id)) {
         return false;
     }
     $the_post = get_post($the_post_id);
     $width = problogger_option('jumbotron_width', 'container');
     $the_bg_color = get_post_meta($the_post->ID, '_jumbotron_meta_color_key', true);
     $the_styles = 'style="' . ($the_bg_color ? 'background-color: ' . $the_bg_color . '; ' : '') . 'border-radius: 0;"';
     $the_content = apply_filters('the_content', $the_post->post_content);
     $output = $the_content;
     switch ($width) {
         case 'full':
             $output = sprintf('<section class="jumbotron" %s>%s</section>', $the_styles, $the_content);
             break;
         case 'fullcontain':
             $output = sprintf('<section class="jumbotron" %s><div class="container">%s</div></section>', $the_styles, $the_content);
             break;
         case 'container':
         default:
             $output = sprintf('<section class="jumbotron container" %s>%s</section>', $the_styles, $the_content);
             break;
     }
     return print $output;
 }
Example #5
0
/**
 * Saves the video embed code on post save
 *
 * @since 4.0
 */
function medium_save_video_meta($post_id)
{
    global $post;
    // Return early if this is a newly created post that hasn't been saved yet.
    if ('auto-draft' == get_post_status($post_id)) {
        return $post_id;
    }
    // Check if the user intended to change this value.
    if (!isset($_POST['medium_video_box_nonce']) || !wp_verify_nonce($_POST['medium_video_box_nonce'], plugin_basename(__FILE__))) {
        return $post_id;
    }
    // Get post type object
    $post_type = get_post_type_object($post->post_type);
    // Check if user has permission
    if (!current_user_can($post_type->cap->edit_post, $post_id)) {
        return $post_id;
    }
    // Get posted data and sanitize it
    $new_video = isset($_POST['medium_video_field']) ? $_POST['medium_video_field'] : '';
    // Get existing video
    $video = get_post_meta($post_id, 'video', true);
    // If a new video was submitted and there was no previous one, add it
    if ($new_video && '' == $video) {
        add_post_meta($post_id, 'video', $new_video, true);
    } elseif ($new_video && $new_video != $video) {
        update_post_meta($post_id, 'video', $new_video);
    } elseif ('' == $new_video && $video) {
        delete_post_meta($post_id, 'video', $video);
    }
}
 function ajax_post()
 {
     require_once ABSPATH . '/wp-admin/includes/post.php';
     if (!wp_verify_nonce($_POST['_wpnonce'], 'update-post_' . $_POST['post_ID'])) {
         wp_send_json_error(array('message' => __('You are not allowed to edit this item.')));
     }
     $_POST['post_title'] = strip_tags($_POST['post_title']);
     $post_id = edit_post();
     if (isset($_POST['save']) || isset($_POST['publish'])) {
         $status = get_post_status($post_id);
         if (isset($_POST['publish'])) {
             switch ($status) {
                 case 'pending':
                     $message = 8;
                     break;
                 case 'future':
                     $message = 9;
                     break;
                 default:
                     $message = 6;
             }
         } else {
             $message = 'draft' == $status ? 10 : 1;
         }
     } else {
         $message = 4;
     }
     $post = get_post($post_id);
     wp_send_json_success(array('message' => $this->get_message($post, $message), 'post' => $post, 'processedPostContent' => apply_filters('the_content', $post->post_content)));
 }
Example #7
0
/**
 * Redirect to previous page.
 *
 * @param int $post_id Optional. Post ID.
 */
function redirect_post($post_id = '', $_url)
{
    $_url = esc_url(add_query_arg('form', $post_id, $_url));
    if (isset($_POST['save']) || isset($_POST['publish'])) {
        $status = get_post_status($post_id);
        if (isset($_POST['publish'])) {
            switch ($status) {
                case 'pending':
                    $message = 8;
                    break;
                case 'future':
                    $message = 9;
                    break;
                default:
                    $message = 6;
            }
        } else {
            $message = 'draft' == $status ? 10 : 1;
        }
        $location = add_query_arg('message', $message, $_url);
    } else {
        $location = add_query_arg('message', 4, $_url);
    }
    wp_redirect(esc_url($location));
    exit;
}
 /**
  * Static method that is fired right after a donation is completed, sending the donation receipt.
  *
  * @param   int     $donation_id
  * @return  boolean
  * @access  public
  * @static
  * @since   1.0.0
  */
 public static function send_with_donation_id($donation_id)
 {
     if (!charitable_get_helper('emails')->is_enabled_email(self::get_email_id())) {
         return false;
     }
     if (!charitable_is_approved_status(get_post_status($donation_id))) {
         return false;
     }
     $donation = charitable_get_donation($donation_id);
     if (!is_object($donation) || 0 == count($donation->get_campaign_donations())) {
         return false;
     }
     if (!apply_filters('charitable_send_' . self::get_email_id(), true, $donation)) {
         return false;
     }
     $email = new Charitable_Email_New_Donation(array('donation' => $donation));
     /**
      * Don't resend the email.
      */
     if ($email->is_sent_already($donation_id)) {
         return false;
     }
     $sent = $email->send();
     /**
      * Log that the email was sent.
      */
     if (apply_filters('charitable_log_email_send', true, self::get_email_id(), $email)) {
         $email->log($donation_id, $sent);
     }
     return true;
 }
Example #9
0
 function rockAjax_save()
 {
     if (!isset($_POST['serializedArray'])) {
         return;
     }
     if (!is_admin()) {
         return;
     }
     // get the submitted parameters
     $postID = (int) $_POST['postID'];
     if (!is_string(get_post_status($postID))) {
         return;
     }
     $array = $_POST['serializedArray'];
     $_builder_in_use = isset($_POST['_builder_in_use']) ? $_POST['_builder_in_use'] : 'false';
     $_featured_image_in_builder = $_POST['featuredInBuilder'];
     update_post_meta($postID, '_this_r_content', addslashes($array));
     update_post_meta($postID, '_builder_in_use', $_builder_in_use);
     update_post_meta($postID, '_featured_image_in_builder', $_featured_image_in_builder);
     // generate the response
     $response = json_encode(array('success' => true));
     // response output
     echo $response;
     exit;
 }
 function show_pending_post_notice($user_id, $post_id)
 {
     if (get_post_status($post_id) == 'pending') {
         add_action('admin_footer', 'disable_review_button');
         add_action('admin_head', 'disable_review_button_styles');
     }
 }
 public function save()
 {
     $parent = get_post($this->parent_id);
     $post_to_save = get_object_vars($parent);
     unset($post_to_save['ID']);
     unset($post_to_save['guid']);
     $post_to_save['post_parent'] = $parent->ID;
     $post_to_save['post_name'] = $parent->post_name . '-' . $this->start_date->format('Y-m-d');
     $duration = $this->get_duration();
     $end_date = $this->get_end_date();
     if (!empty($this->post_id)) {
         // update the existing post
         $post_to_save['ID'] = $this->post_id;
         if (get_post_status($this->post_id) == 'trash') {
             $post_to_save['post_status'] = get_post_status($this->post_id);
         }
         $this->post_id = wp_update_post($post_to_save);
         update_post_meta($this->post_id, '_EventStartDate', $this->start_date->format(DateSeriesRules::DATE_FORMAT));
         update_post_meta($this->post_id, '_EventEndDate', $end_date->format(DateSeriesRules::DATE_FORMAT));
         update_post_meta($this->post_id, '_EventDuration', $duration);
     } else {
         // add a new post
         $post_to_save['guid'] = esc_url(add_query_arg(array('eventDate' => $this->start_date->format('Y-m-d')), $parent->guid));
         $this->post_id = wp_insert_post($post_to_save);
         // save several queries by calling add_post_meta when we have a new post
         add_post_meta($this->post_id, '_EventStartDate', $this->start_date->format(DateSeriesRules::DATE_FORMAT));
         add_post_meta($this->post_id, '_EventEndDate', $end_date->format(DateSeriesRules::DATE_FORMAT));
         add_post_meta($this->post_id, '_EventDuration', $duration);
     }
     $this->copy_meta();
     // everything else
     $this->set_terms();
 }
 public function valid()
 {
     if (!defined('WPDDL_DEVELOPMENT') && !defined('WPDDL_PRODUCTION')) {
         return false;
     }
     $type = self::get_type_name();
     if (isset(self::$layout_id[$type]) && self::$layout_id[$type] !== null && self::$layout_id !== false) {
         return true;
     }
     global $wpdb;
     $layouts_per_post_type = $wpdb->get_results("SELECT meta_value, post_id FROM {$wpdb->postmeta} WHERE meta_key = '_ddl_post_types_was_batched'");
     foreach ($layouts_per_post_type as $setting) {
         $setting->meta_value = unserialize($setting->meta_value);
         if (is_array($setting->meta_value) && in_array($type, $setting->meta_value)) {
             if (get_post_status($setting->post_id) == 'trash') {
                 continue;
             }
             $title = get_the_title($setting->post_id);
             self::$layout_id[$type] = $setting->post_id;
             self::$layout_name[$type] = $title;
             return true;
         }
     }
     self::$layout_id[$type] = false;
     self::$layout_name[$type] = false;
     return false;
 }
Example #13
0
 function form_init()
 {
     global $ultimatemember;
     $http_post = 'POST' == $_SERVER['REQUEST_METHOD'];
     if ($http_post && !is_admin() && isset($_POST['form_id']) && is_numeric($_POST['form_id'])) {
         $this->form_id = $_POST['form_id'];
         $this->form_status = get_post_status($this->form_id);
         if ($this->form_status == 'publish') {
             /* save entire form as global */
             $this->post_form = $_POST;
             $this->post_form = $this->beautify($this->post_form);
             $this->form_data = $ultimatemember->query->post_data($this->form_id);
             $this->post_form['submitted'] = $this->post_form;
             $this->post_form = array_merge($this->form_data, $this->post_form);
             if ($_POST[$ultimatemember->honeypot] != '') {
                 wp_die('Hello, spam bot!');
             }
             if (!in_array($this->form_data['mode'], array('login'))) {
                 $form_timestamp = trim($_POST['timestamp']);
                 $live_timestamp = current_time('timestamp');
                 if ($form_timestamp == '' && um_get_option('enable_timebot') == 1) {
                     wp_die(__('Hello, spam bot!'));
                 }
                 if ($live_timestamp - $form_timestamp < 6 && um_get_option('enable_timebot') == 1) {
                     wp_die(__('Whoa, slow down! You\'re seeing this message because you tried to submit a form too fast and we think you might be a spam bot. If you are a real human being please wait a few seconds before submitting the form. Thanks!'));
                 }
             }
             /* Continue based on form mode - pre-validation */
             do_action('um_submit_form_errors_hook', $this->post_form);
             do_action("um_submit_form_{$this->post_form['mode']}", $this->post_form);
         }
     }
 }
function fnt_dashboard_widget()
{
    $clientid = '9f690b3117f0c43767528e2b60bc70ce';
    $args = array('posts_per_page' => -1, 'offset' => 0, 'post_status' => array('publish', 'draft'), 'post_type' => 'tracks');
    $errors = 0;
    $query = new WP_Query($args);
    while ($query->have_posts()) {
        $query->the_post();
        $id = get_the_ID();
        $track_url = get_post_meta($id, 'track_url', true);
        $errored = 0;
        if (get_post_status() == 'draft') {
            $errored = 1;
        } else {
            $soundcloud_url = 'https://api.soundcloud.com/resolve?url=' . $track_url . '&format=json&consumer_key=' . $clientid;
            $track_json = file_get_contents($soundcloud_url);
            $track = json_decode($track_json);
            if ($track == null || isset($track->errors) && isset($track->errors[0]) && $track->errors[0]->error_message == '404 - Not Found' || $track->errors[0]->error_message == 'HTTP Error: 403') {
                $errored = 1;
                $update = array('ID' => $id, 'post_status' => 'draft');
                wp_update_post($update);
            }
        }
        if ($errored > 0) {
            echo '<span style="color:red;">SC Track is private & won\'t play: </span>&nbsp;' . '<a href="' . get_edit_post_link() . '" target="_blank">' . get_the_title() . '</a><br/>';
            $errors++;
        }
    }
    if ($errors > 0) {
        echo '<br/><em>These ' . $errors . ' posts are all drafts, but should probably be fixed or removed.</em>';
    } else {
        echo 'There are no broken tracks! That is SHOCKING :)';
    }
}
 /**
  * Constructor.
  */
 public function __construct()
 {
     add_action('wp', array($this, 'process'));
     $this->steps = (array) apply_filters('submit_resume_steps', array('submit' => array('name' => __('Submit Details', 'wp-job-manager-resumes'), 'view' => array($this, 'submit'), 'handler' => array($this, 'submit_handler'), 'priority' => 10), 'preview' => array('name' => __('Preview', 'wp-job-manager-resumes'), 'view' => array($this, 'preview'), 'handler' => array($this, 'preview_handler'), 'priority' => 20), 'done' => array('name' => __('Done', 'wp-job-manager-resumes'), 'view' => array($this, 'done'), 'handler' => '', 'priority' => 30)));
     uasort($this->steps, array($this, 'sort_by_priority'));
     // Get step/resume
     if (!empty($_REQUEST['step'])) {
         $this->step = is_numeric($_REQUEST['step']) ? max(absint($_REQUEST['step']), 0) : array_search($_REQUEST['step'], array_keys($this->steps));
     }
     $this->resume_id = !empty($_REQUEST['resume_id']) ? absint($_REQUEST['resume_id']) : 0;
     $this->job_id = !empty($_REQUEST['job_id']) ? absint($_REQUEST['job_id']) : 0;
     // Load resume details
     if ($this->resume_id) {
         $resume_status = get_post_status($this->resume_id);
         if ('expired' === $resume_status) {
             if (!resume_manager_user_can_edit_resume($this->resume_id)) {
                 $this->resume_id = 0;
                 $this->job_id = 0;
                 $this->step = 0;
             }
         } elseif (0 === $this->step && !in_array($resume_status, apply_filters('resume_manager_valid_submit_resume_statuses', array('preview'))) && empty($_POST['resume_application_submit_button'])) {
             $this->resume_id = 0;
             $this->job_id = 0;
             $this->step = 0;
         }
     }
 }
Example #16
0
 /**
  * Registers the Polylang language meta box.
  *
  * @param  object $post WP_Post post object.
  * @param  array  $metabox Array of metabox arguments.
  *
  * @return void.
  */
 public static function polylangMetaBoxRender($post, $metabox)
 {
     global $polylang;
     $post_id = $post->ID;
     $post_type = $metabox['args']['post_type'];
     if ($lg = $polylang->model->get_post_language($post_id)) {
         $lang = $lg;
     } elseif (!empty($_GET['new_lang'])) {
         $lang = $polylang->model->get_language($_GET['new_lang']);
     } else {
         $lang = $polylang->pref_lang;
     }
     $text_domain = Plugin::TEXT_DOMAIN;
     $languages = $polylang->model->get_languages_list();
     $pll_dropdown = new PLL_Walker_Dropdown();
     $dropdown = $pll_dropdown->walk($languages, array('name' => 'post_lang_choice', 'class' => 'tags-input', 'selected' => $lang ? $lang->slug : '', 'flag' => true));
     foreach ($languages as $key_language => $language) {
         if ($language->term_id == $lang->term_id) {
             unset($languages[$key_language]);
             $languages = array_values($languages);
             break;
         }
     }
     wp_nonce_field('pll_language', '_pll_nonce');
     $is_autopost = get_post_status($post) == 'auto-draft';
     include Trapp\instance()->plugin_dir . 'views/admin/metabox-translations-post/language.php';
     if (!$is_autopost) {
         include Trapp\instance()->plugin_dir . 'views/admin/metabox-translations-post/translations.php';
         include Trapp\instance()->plugin_dir . 'views/admin/metabox-translations-post/trapp.php';
     }
 }
 function get_assigned_courses_ids($status = 'all')
 {
     global $wpdb;
     $assigned_courses = array();
     $courses = Instructor::get_course_meta_keys($this->ID);
     foreach ($courses as $course) {
         $course_id = $course;
         // Dealing with multisite nuances
         if (is_multisite()) {
             // Primary blog?
             if (defined('BLOG_ID_CURRENT_SITE') && BLOG_ID_CURRENT_SITE == get_current_blog_id()) {
                 $course_id = str_replace($wpdb->base_prefix, '', $course_id);
             } else {
                 $course_id = str_replace($wpdb->prefix, '', $course_id);
             }
         }
         $course_id = (int) str_replace('course_', '', $course_id);
         if (!empty($course_id)) {
             if ($status !== 'all') {
                 if (get_post_status($course_id) == $status) {
                     $assigned_courses[] = $course_id;
                 }
             } else {
                 $assigned_courses[] = $course_id;
             }
         }
     }
     return $assigned_courses;
 }
/**
 * Sanitizes post_id in slider
 * @param  $input entered value
 * @return sanitized output
 *
 * @since Catch Box 1.4
 */
function catchbox_sanitize_post_id($input)
{
    // Ensure $input is an absolute integer.
    $post_id = absint($input);
    // If $page_id is an ID of a published page, return it; otherwise, return empty
    return 'publish' == get_post_status($post_id) ? $post_id : '';
}
 public function get_frontend_data($post_id)
 {
     $collector = array();
     $meta = fw_get_db_post_option($post_id);
     $post_status = get_post_status($post_id);
     if ('publish' === $post_status and isset($meta['populated'])) {
         $slider_name = $meta['slider']['selected'];
         $population_method = $meta['slider'][$slider_name]['population-method'];
         $number_of_images = (int) $meta['number_of_images'];
         $collector = array('slides' => array(), 'settings' => array('title' => $meta['title'], 'slider_type' => $slider_name, 'population_method' => $population_method, 'post_id' => $post_id, 'extra' => isset($meta['custom-settings']) ? $meta['custom-settings'] : array()));
         $query_data = array();
         $post_type = $meta['tags']['selected'];
         $terms = $meta['tags'][$post_type]['terms'];
         $tax_query = array('tax_query' => array('relation' => 'OR'));
         foreach ($terms as $term) {
             $decoded_data = json_decode($term, true);
             $query_data[$decoded_data['taxonomy']][] = $decoded_data['term_id'];
         }
         foreach ($query_data as $taxonomy => $terms) {
             $tax_query['tax_query'][] = array('taxonomy' => $taxonomy, 'field' => 'id', 'terms' => $terms);
         }
         $final_query = array_merge(array('post_status' => 'publish', 'posts_per_page' => $number_of_images, 'post_type' => $post_type, 'meta_key' => '_thumbnail_id'), $tax_query);
         global $post;
         $original_post = $post;
         $the_query = new WP_Query($final_query);
         while ($the_query->have_posts()) {
             $the_query->the_post();
             array_push($collector['slides'], array('title' => get_the_title(), 'multimedia_type' => $this->multimedia_types[0], 'src' => wp_get_attachment_url(get_post_thumbnail_id(get_the_ID())), 'desc' => get_the_excerpt(), 'extra' => array('post_id' => $post->ID)));
         }
         wp_reset_postdata();
         $post = $original_post;
         unset($original_post);
     }
     return $collector;
 }
Example #20
0
 public function valid()
 {
     // false if views not active
     if (!parent::valid()) {
         return false;
     }
     global $wpdb;
     $cpt = Types_Helper_Condition::get_post_type();
     if (isset(self::$views_per_post_type[$cpt->name])) {
         return true;
     }
     // @todo check with Juan if views has a get_views_of_post_type() function
     $views_settings = $wpdb->get_results("SELECT meta_value, post_id FROM {$wpdb->postmeta} WHERE meta_key = '_wpv_settings'");
     foreach ($views_settings as $setting) {
         $setting->meta_value = unserialize($setting->meta_value);
         if (isset($setting->meta_value['post_type']) && in_array($cpt->name, $setting->meta_value['post_type'])) {
             if (get_post_status($setting->post_id) == 'trash') {
                 continue;
             }
             $title = get_the_title($setting->post_id);
             self::$views_per_post_type[$cpt->name][] = array('id' => $setting->post_id, 'name' => $title);
         }
     }
     if (isset(self::$views_per_post_type[$cpt->name])) {
         return true;
     }
     return false;
 }
 /**
  * Constructor.
  */
 public function __construct()
 {
     add_action('wp', array($this, 'process'));
     $this->steps = (array) apply_filters('submit_job_steps', array('submit' => array('name' => __('Submit Details', 'wp-job-manager'), 'view' => array($this, 'submit'), 'handler' => array($this, 'submit_handler'), 'priority' => 10), 'preview' => array('name' => __('Preview', 'wp-job-manager'), 'view' => array($this, 'preview'), 'handler' => array($this, 'preview_handler'), 'priority' => 20), 'done' => array('name' => __('Done', 'wp-job-manager'), 'view' => array($this, 'done'), 'priority' => 30)));
     uasort($this->steps, array($this, 'sort_by_priority'));
     // Get step/job
     if (isset($_POST['step'])) {
         $this->step = is_numeric($_POST['step']) ? max(absint($_POST['step']), 0) : array_search($_POST['step'], array_keys($this->steps));
     } elseif (!empty($_GET['step'])) {
         $this->step = is_numeric($_GET['step']) ? max(absint($_GET['step']), 0) : array_search($_GET['step'], array_keys($this->steps));
     }
     $this->job_id = !empty($_REQUEST['job_id']) ? absint($_REQUEST['job_id']) : 0;
     // Allow resuming from cookie.
     if (!$this->job_id && !empty($_COOKIE['wp-job-manager-submitting-job-id']) && !empty($_COOKIE['wp-job-manager-submitting-job-key'])) {
         $job_id = absint($_COOKIE['wp-job-manager-submitting-job-id']);
         $job_status = get_post_status($job_id);
         if ('preview' === $job_status && get_post_meta($job_id, '_submitting_key', true) === $_COOKIE['wp-job-manager-submitting-job-key']) {
             $this->job_id = $job_id;
         }
     }
     // Load job details
     if ($this->job_id) {
         $job_status = get_post_status($this->job_id);
         if ('expired' === $job_status) {
             if (!job_manager_user_can_edit_job($this->job_id)) {
                 $this->job_id = 0;
                 $this->step = 0;
             }
         } elseif (!in_array($job_status, apply_filters('job_manager_valid_submit_job_statuses', array('preview')))) {
             $this->job_id = 0;
             $this->step = 0;
         }
     }
 }
Example #22
0
/**
 * Redirect to previous page.
 *
 * @param int $post_id Optional. Post ID.
 */
function redirect_post($post_id = '')
{
    if (isset($_POST['save']) || isset($_POST['publish'])) {
        $status = get_post_status($post_id);
        if (isset($_POST['publish'])) {
            switch ($status) {
                case 'pending':
                    $message = 8;
                    break;
                case 'future':
                    $message = 9;
                    break;
                default:
                    $message = 6;
            }
        } else {
            $message = 'draft' == $status ? 10 : 1;
        }
        $location = add_query_arg('message', $message, get_edit_post_link($post_id, 'url'));
    } elseif (isset($_POST['addmeta']) && $_POST['addmeta']) {
        $location = add_query_arg('message', 2, wp_get_referer());
        $location = explode('#', $location);
        $location = $location[0] . '#postcustom';
    } elseif (isset($_POST['deletemeta']) && $_POST['deletemeta']) {
        $location = add_query_arg('message', 3, wp_get_referer());
        $location = explode('#', $location);
        $location = $location[0] . '#postcustom';
    } elseif ('post-quickpress-save-cont' == $_POST['action']) {
        $location = "post.php?action=edit&post={$post_id}&message=7";
    } else {
        $location = add_query_arg('message', 4, get_edit_post_link($post_id, 'url'));
    }
    wp_redirect(apply_filters('redirect_post_location', $location, $post_id));
    exit;
}
Example #23
0
 /**
  * Callback for post changing events to purge URLs.
  *
  * @param  int $post_id Post ID.
  * @return void
  */
 public function purge($post_id)
 {
     if (!in_array(get_post_status($post_id), array('publish', 'trash'))) {
         return;
     }
     purgely_purge_surrogate_key('post-' . absint($post_id));
 }
function bh_ep_render_send_metabox($post)
{
    if (get_post_status($post) == 'auto-draft' || get_post_status($post) == 'draft') {
        $button_text = 'Publish and Share';
    } else {
        if (get_post_status($post) == 'publish') {
            $button_text = 'Share';
        } else {
            $button_text = 'Cannot Share in this state';
        }
    }
    ?>
	<!-- on click call JQeury function   -->
	<p id="state">Not Sent</p>
        <button class="button button-large" onclick="sendEvent()" id="bh-ep-event-send"><?php 
    _e($button_text);
    ?>
</button>
<script>
function sendEvent() {
	//foo for testing, "test.asp" for testing 
	var posting = $.post('http://cs.redeemer.ca/~bhealey/wp-content/plugins/event_press/includes/test.asp', "foo");
	document.getElementById("state").innerHTML = posting; 
}
</script>
<?php 
    // jQuery.post(); JSON to server
    //create Urbanicity page as server
}
/**
 * Sanitizes page/post
 * @param  $input entered value
 * @return sanitized output
 *
 * @since Catch Adaptive 0.1
 */
function create_sanitize_page($input)
{
    // Ensure $input is an absolute integer.
    $page_id = absint($input);
    // If $page_id is an ID of a published page, return it; otherwise, return false
    return 'publish' == get_post_status($page_id) ? $page_id : false;
}
Example #26
0
 /**
  * Instantiates this class
  *
  * @param int $id ID of the attachment
  */
 public function __construct($id)
 {
     // Check if post exists
     if (!is_string(get_post_status($id))) {
         throw new \Exception("Post does not exist");
     }
     // Check if post is an attachment
     if (get_post_type($id) != 'attachment') {
         throw new \Exception("Target post is not an attachment");
     }
     // Check if attachment have a file path to use
     $this->partial_path = get_post_meta($id, '_wp_attached_file', true);
     if (!$this->partial_path) {
         throw new \Exception("Target post does not have a file path to be used");
     }
     // Collect environment information if not already available
     if (is_null(static::$env)) {
         static::$env = static::__getEnvInfo();
     }
     // Get WordPress meta data
     $default_wordpress_meta = ['sizes' => []];
     $this->wordpress_meta = get_post_meta($id, '_wp_attachment_metadata', true) ?: $default_wordpress_meta;
     // Get plugin meta data
     $default_plugin_meta = ['sizes' => []];
     $plugin_meta_json = get_post_meta($id, Config::ATTACHMENT_META_KEY, true);
     $this->plugin_meta = $plugin_meta_json ? json_decode($plugin_meta_json, true) : $default_plugin_meta;
     // Store post id
     $this->id = $id;
 }
Example #27
0
 function emg_load_wp_enqueue()
 {
     if (get_post_type(get_the_ID()) == 'easymediagallery') {
         $eparams = array('pcnt' => emg_pcnt(), 'psts' => get_post_status(get_the_ID()), 'pcurtp' => get_post_meta(get_the_ID(), 'easmedia_metabox_media_type', true));
         wp_localize_script('cpscript', 'easyMeta', $eparams);
         if (EMG_WP_VER == "g35") {
             wp_enqueue_media();
         }
         wp_enqueue_script('jquery-multi-sel');
         wp_enqueue_style('jquery-multiselect-css');
         wp_enqueue_style('jquery-ui-themes-redmond');
         wp_enqueue_style('emg-bootstrap-css');
         wp_enqueue_script('jquery-ui');
         wp_enqueue_script('jquery-effects-highlight');
         wp_enqueue_script('easymedia-jplayer-js', plugins_url('js/jplayer/jquery.jplayer.min.js', __FILE__));
         wp_enqueue_script('cpscript');
         wp_enqueue_script('jquery-i-button', plugins_url('js/jquery/jquery.ibutton.js', __FILE__));
         wp_enqueue_style('metabox-ibuttoneditor', plugins_url('css/ibutton.css', __FILE__), false, EASYMEDIA_VERSION);
         wp_enqueue_style('easymedia-jplayer-css', plugins_url('css/jplayer/skin/pink.flag/jplayer.pink.flag.css', __FILE__), false, EASYMEDIA_VERSION);
         wp_enqueue_style('jquery-messi-css');
         wp_enqueue_script('jquery-messi-js');
         wp_enqueue_script('emg-bootstrap-js');
         wp_enqueue_script('easymedia-metascript', plugins_url('functions/metabox/metabox.js', __FILE__));
         // @since 1.3.10 >
         if (easy_get_option('easymedia_disen_autoupdt') != '1' && is_admin()) {
             add_action('admin_notices', 'easmedia_update_notify');
         }
     }
 }
    /**
     * Adds the custom button into the post edit page
     */
    public static function add_button()
    {
        // work out if post is published or not
        $status = get_post_status($_GET['post']);
        // if the post is already published, label the button as "update"
        $button_label = $status == 'publish' || $status == 'private' ? 'Update and Visit' : 'Publish and Visit';
        // TODO: fix duplicated IDs
        //var_dump($_SERVER['HTTP_REFERER']);
        ?>

		<div id="major-publishing-actions" style="overflow:hidden">
			<div id="publishing-action">
				<input type="hidden" name="savevisit_referer" value="<?php 
        echo $_SERVER['HTTP_REFERER'];
        ?>
">
				<input type="submit" tabindex="5" value="<?php 
        echo $button_label;
        ?>
" class="button-primary" id="cbxsaveandvisitbtn" name="save-visit">
			</div>
		</div>

		<?php 
    }
 function __construct($id = '', $status = 'any', $output = 'OBJECT')
 {
     $continue = true;
     if ($status !== 'any') {
         if (get_post_status($id) == $status) {
             $continue = true;
         } else {
             $continue = false;
         }
     }
     if ($continue) {
         $this->id = $id;
         $this->output = $output;
         $this->details = get_post($this->id, $this->output);
         $tickets = new TC_Tickets();
         $fields = $tickets->get_ticket_fields();
         if (isset($this->details)) {
             if (!empty($fields)) {
                 foreach ($fields as $field) {
                     if (!isset($this->details->{$field['field_name']})) {
                         $this->details->{$field['field_name']} = get_post_meta($this->id, $field['field_name'], true);
                     }
                 }
             }
         }
     } else {
         $this->id = null;
     }
 }
 public function staticpress_save_single($postId)
 {
     if (get_post_status($postId) === 'publish' && !post_password_required($postId)) {
         $url = get_permalink($postId);
         $this->create_static_file($url, 'other_page', false, true);
     }
 }