function __construct($args)
 {
     if (is_array($this->post_object_format) && isset($this->post_object_format['format'])) {
         $this->post_object_format['format'] = get_post_format_strings();
     }
     if (!$this->response_format) {
         $this->response_format =& $this->post_object_format;
     }
     parent::__construct($args);
 }
 function get_post_formats()
 {
     // deprecated - see separate endpoint. get a list of supported post formats
     $all_formats = get_post_format_strings();
     $supported = $this->get_theme_support('post-formats');
     $supported_formats = array();
     if (isset($supported[0])) {
         foreach ($supported[0] as $format) {
             $supported_formats[$format] = $all_formats[$format];
         }
     }
     return $supported_formats;
 }
Esempio n. 3
0
function A_show_post_formats($key, $details)
{
    $table = maybe_unserialize($details->feed_meta);
    echo "<tr>";
    echo "<td valign='top' class='heading'>";
    echo __('Post format for new posts', 'autoblogtext');
    echo "</td>";
    echo "<td valign='top' class=''>";
    $formats = get_post_format_strings();
    echo "<select name='abtble[postformat]' class='field'>";
    foreach ($formats as $key => $format) {
        echo "<option value='" . $key . "'";
        echo $table['postformat'] == $key ? " selected='selected'" : "";
        echo ">" . $format . "</option>";
    }
    echo "</select>" . "<a href='#' class='info' title='" . __('Select the post format the imported posts will have in the blog.', 'autoblogtext') . "'></a>";
    echo "</td>";
    echo "</tr>\n";
}
 /**
  * Creates an array of ElasticSearch filters based on the post_id and args.
  *
  * @param int $post_id
  * @param array $args
  * @uses apply_filters, get_post_types, get_post_format_strings
  * @return array
  */
 protected function _get_es_filters_from_args($post_id, array $args)
 {
     $filters = array();
     /**
      * Filter the terms used to search for Related Posts.
      *
      * @module related-posts
      *
      * @since 2.8.0
      *
      * @param array $args['has_terms'] Array of terms associated to the Related Posts.
      * @param string $post_id Post ID of the post for which we are retrieving Related Posts.
      */
     $args['has_terms'] = apply_filters('jetpack_relatedposts_filter_has_terms', $args['has_terms'], $post_id);
     if (!empty($args['has_terms'])) {
         foreach ((array) $args['has_terms'] as $term) {
             if (mb_strlen($term->taxonomy)) {
                 switch ($term->taxonomy) {
                     case 'post_tag':
                         $tax_fld = 'tag.slug';
                         break;
                     case 'category':
                         $tax_fld = 'category.slug';
                         break;
                     default:
                         $tax_fld = 'taxonomy.' . $term->taxonomy . '.slug';
                         break;
                 }
                 $filters[] = array('term' => array($tax_fld => $term->slug));
             }
         }
     }
     /**
      * Filter the Post Types where we search Related Posts.
      *
      * @module related-posts
      *
      * @since 2.8.0
      *
      * @param array $args['post_type'] Array of Post Types.
      * @param string $post_id Post ID of the post for which we are retrieving Related Posts.
      */
     $args['post_type'] = apply_filters('jetpack_relatedposts_filter_post_type', $args['post_type'], $post_id);
     $valid_post_types = get_post_types();
     if (is_array($args['post_type'])) {
         $sanitized_post_types = array();
         foreach ($args['post_type'] as $pt) {
             if (in_array($pt, $valid_post_types)) {
                 $sanitized_post_types[] = $pt;
             }
         }
         if (!empty($sanitized_post_types)) {
             $filters[] = array('terms' => array('post_type' => $sanitized_post_types));
         }
     } else {
         if (in_array($args['post_type'], $valid_post_types) && 'all' != $args['post_type']) {
             $filters[] = array('term' => array('post_type' => $args['post_type']));
         }
     }
     /**
      * Filter the Post Formats where we search Related Posts.
      *
      * @module related-posts
      *
      * @since 3.3.0
      *
      * @param array $args['post_formats'] Array of Post Formats.
      * @param string $post_id Post ID of the post for which we are retrieving Related Posts.
      */
     $args['post_formats'] = apply_filters('jetpack_relatedposts_filter_post_formats', $args['post_formats'], $post_id);
     $valid_post_formats = get_post_format_strings();
     $sanitized_post_formats = array();
     foreach ($args['post_formats'] as $pf) {
         if (array_key_exists($pf, $valid_post_formats)) {
             $sanitized_post_formats[] = $pf;
         }
     }
     if (!empty($sanitized_post_formats)) {
         $filters[] = array('terms' => array('post_format' => $sanitized_post_formats));
     }
     /**
      * Filter the date range used to search Related Posts.
      *
      * @module related-posts
      *
      * @since 2.8.0
      *
      * @param array $args['date_range'] Array of a month interval where we search Related Posts.
      * @param string $post_id Post ID of the post for which we are retrieving Related Posts.
      */
     $args['date_range'] = apply_filters('jetpack_relatedposts_filter_date_range', $args['date_range'], $post_id);
     if (is_array($args['date_range']) && !empty($args['date_range'])) {
         $args['date_range'] = array_map('intval', $args['date_range']);
         if (!empty($args['date_range']['from']) && !empty($args['date_range']['to'])) {
             $filters[] = array('range' => array('date_gmt' => $this->_get_coalesced_range($args['date_range'])));
         }
     }
     /**
      * Filter the Post IDs excluded from appearing in Related Posts.
      *
      * @module related-posts
      *
      * @since 2.9.0
      *
      * @param array $args['exclude_post_ids'] Array of Post IDs.
      * @param string $post_id Post ID of the post for which we are retrieving Related Posts.
      */
     $args['exclude_post_ids'] = apply_filters('jetpack_relatedposts_filter_exclude_post_ids', $args['exclude_post_ids'], $post_id);
     if (!empty($args['exclude_post_ids']) && is_array($args['exclude_post_ids'])) {
         foreach ($args['exclude_post_ids'] as $exclude_post_id) {
             $exclude_post_id = (int) $exclude_post_id;
             if ($exclude_post_id > 0) {
                 $filters[] = array('not' => array('term' => array('post_id' => $exclude_post_id)));
             }
         }
     }
     return $filters;
 }
 function callback($path = '', $blog_id = 0)
 {
     $blog_id = $this->api->switch_to_blog_and_validate_user($this->api->get_blog_id($blog_id));
     if (is_wp_error($blog_id)) {
         return $blog_id;
     }
     if (defined('IS_WPCOM') && IS_WPCOM) {
         $this->load_theme_functions();
     }
     // Get a list of supported post formats.
     $all_formats = get_post_format_strings();
     $supported = get_theme_support('post-formats');
     $supported_formats = $response['formats'] = array();
     if (isset($supported[0])) {
         foreach ($supported[0] as $format) {
             $supported_formats[$format] = $all_formats[$format];
         }
     }
     $response['formats'] = (object) $supported_formats;
     return $response;
 }
Esempio n. 6
0
 function render_location_value($options)
 {
     // vars
     $options = wp_parse_args($options, array('group_id' => 0, 'rule_id' => 0, 'value' => null, 'param' => null));
     // vars
     $choices = array();
     // some case's have the same outcome
     if ($options['param'] == "page_parent") {
         $options['param'] = "page";
     }
     switch ($options['param']) {
         /*
          *  Basic
          */
         case "post_type":
             // all post types except attachment
             $exclude = array('attachment');
             $choices = acf_get_post_types($exclude);
             $choices = acf_get_pretty_post_types($choices);
             break;
         case "user_type":
             global $wp_roles;
             $choices = $wp_roles->get_names();
             if (is_multisite()) {
                 $choices['super_admin'] = __('Super Admin');
             }
             break;
             /*
              *  Post
              */
         /*
          *  Post
          */
         case "post":
             // get post types
             $exclude = array('page', 'attachment');
             $post_types = acf_get_post_types($exclude);
             // get posts grouped by post type
             $groups = acf_get_posts(array('post_type' => $post_types));
             if (!empty($groups)) {
                 foreach (array_keys($groups) as $group_title) {
                     // vars
                     $posts = acf_extract_var($groups, $group_title);
                     // override post data
                     foreach (array_keys($posts) as $post_id) {
                         // update
                         $posts[$post_id] = acf_get_post_title($posts[$post_id]);
                     }
                     // append to $choices
                     $choices[$group_title] = $posts;
                 }
             }
             break;
         case "post_category":
             $terms = acf_get_taxonomy_terms('category');
             if (!empty($terms)) {
                 $choices = array_pop($terms);
             }
             break;
         case "post_format":
             $choices = get_post_format_strings();
             break;
         case "post_status":
             $choices = array('publish' => __('Publish', 'acf'), 'pending' => __('Pending Review', 'acf'), 'draft' => __('Draft', 'acf'), 'future' => __('Future', 'acf'), 'private' => __('Private', 'acf'), 'inherit' => __('Revision', 'acf'), 'trash' => __('Trash', 'acf'));
             break;
         case "post_taxonomy":
             $choices = acf_get_taxonomy_terms();
             // unset post_format
             if (isset($choices['post_format'])) {
                 unset($choices['post_format']);
             }
             break;
             /*
              *  Page
              */
         /*
          *  Page
          */
         case "page":
             // get posts grouped by post type
             $groups = acf_get_posts(array('post_type' => 'page'));
             if (!empty($groups)) {
                 foreach (array_keys($groups) as $group_title) {
                     // vars
                     $posts = acf_extract_var($groups, $group_title);
                     // override post data
                     foreach (array_keys($posts) as $post_id) {
                         // update
                         $posts[$post_id] = acf_get_post_title($posts[$post_id]);
                     }
                     // append to $choices
                     $choices = $posts;
                 }
             }
             break;
         case "page_type":
             $choices = array('front_page' => __("Front Page", 'acf'), 'posts_page' => __("Posts Page", 'acf'), 'top_level' => __("Top Level Page (parent of 0)", 'acf'), 'parent' => __("Parent Page (has children)", 'acf'), 'child' => __("Child Page (has parent)", 'acf'));
             break;
         case "page_parent":
             // refer to "page"
             break;
         case "page_template":
             $choices = array('default' => __("Default Template", 'acf'));
             $templates = get_page_templates();
             foreach ($templates as $k => $v) {
                 $choices[$v] = $k;
             }
             break;
             /*
              *  User
              */
         /*
          *  User
          */
         case "user_role":
             global $wp_roles;
             $choices = array_merge(array('all' => __('All', 'acf')), $wp_roles->get_names());
             break;
         case "user_form":
             $choices = array('all' => __('All', 'acf'), 'edit' => __('Add / Edit', 'acf'), 'register' => __('Register', 'acf'));
             break;
             /*
              *  Forms
              */
         /*
          *  Forms
          */
         case "attachment":
             $choices = array('all' => __('All', 'acf'));
             break;
         case "taxonomy":
             $choices = array_merge(array('all' => __('All', 'acf')), acf_get_taxonomies());
             // unset post_format
             if (isset($choices['post_format'])) {
                 unset($choices['post_format']);
             }
             break;
         case "comment":
             $choices = array('all' => __('All', 'acf'));
             break;
         case "widget":
             global $wp_widget_factory;
             $choices = array('all' => __('All', 'acf'));
             if (!empty($wp_widget_factory->widgets)) {
                 foreach ($wp_widget_factory->widgets as $widget) {
                     $choices[$widget->id_base] = $widget->name;
                 }
             }
             break;
     }
     // allow custom location rules
     $choices = apply_filters('acf/location/rule_values/' . $options['param'], $choices);
     // create field
     acf_render_field(array('type' => 'select', 'prefix' => "acf_field_group[location][{$options['group_id']}][{$options['rule_id']}]", 'name' => 'value', 'value' => $options['value'], 'choices' => $choices));
 }
            }
            ?>
		 </td>
	   </tr>
<?php 
        }
        ?>

<?php 
        if (current_theme_supports('post-formats')) {
            ?>

<?php 
            $post_formats = get_theme_support('post-formats');
            if (is_array($post_formats[0])) {
                $formatName = get_post_format_strings();
                ?>
       <tr>
         <td style="padding:0 0 10px 0;"><?php 
                echo __('Post Format', 'wp-autopost');
                ?>
:</td>
         <td style="padding:0 0 10px 0;">
		   <input type="radio" name="post_format" value="" <?php 
                if ($config->post_format == '' || $config->post_format == null) {
                    echo 'checked="true"';
                }
                ?>
 /> <?php 
                echo $formatName['standard'];
                ?>
Esempio n. 8
0
 function ajax_acf_location($options = array())
 {
     // defaults
     $defaults = array('key' => null, 'value' => null, 'param' => null);
     // Is AJAX call?
     if (isset($_POST['action']) && $_POST['action'] == "acf_location") {
         $options = array_merge($defaults, $_POST);
     } else {
         $options = array_merge($defaults, $options);
     }
     // some case's have the same outcome
     if ($options['param'] == "page_parent") {
         $options['param'] = "page";
     }
     $choices = array();
     $optgroup = false;
     switch ($options['param']) {
         case "post_type":
             $choices = get_post_types(array('public' => true));
             unset($choices['attachment']);
             break;
         case "page":
             $pages = get_pages(array('numberposts' => -1, 'post_type' => 'page', 'sort_column' => 'menu_order', 'order' => 'ASC', 'post_status' => array('publish', 'private', 'draft', 'inherit', 'future'), 'suppress_filters' => false));
             foreach ($pages as $page) {
                 $title = '';
                 $ancestors = get_ancestors($page->ID, 'page');
                 if ($ancestors) {
                     foreach ($ancestors as $a) {
                         $title .= '- ';
                     }
                 }
                 $title .= apply_filters('the_title', $page->post_title, $page->ID);
                 // status
                 if ($page->post_status != "publish") {
                     $title .= " ({$page->post_status})";
                 }
                 $choices[$page->ID] = $title;
             }
             break;
         case "page_type":
             $choices = array('parent' => __("Parent Page", 'acf'), 'child' => __("Child Page", 'acf'));
             break;
         case "page_template":
             $choices = array('default' => __("Default Template", 'acf'));
             $templates = get_page_templates();
             foreach ($templates as $k => $v) {
                 $choices[$v] = $k;
             }
             break;
         case "post":
             $posts = get_posts(array('numberposts' => '-1', 'post_status' => array('publish', 'private', 'draft', 'inherit', 'future'), 'suppress_filters' => false));
             foreach ($posts as $post) {
                 $title = apply_filters('the_title', $post->post_title, $post->ID);
                 // status
                 if ($post->post_status != "publish") {
                     $title .= " ({$post->post_status})";
                 }
                 $choices[$post->ID] = $title;
             }
             break;
         case "post_category":
             $category_ids = get_all_category_ids();
             foreach ($category_ids as $cat_id) {
                 $cat_name = get_cat_name($cat_id);
                 $choices[$cat_id] = $cat_name;
             }
             break;
         case "post_format":
             $choices = get_post_format_strings();
             break;
         case "user_type":
             global $wp_roles;
             $choices = $wp_roles->get_names();
             break;
         case "options_page":
             $choices = array(__('Options', 'acf') => __('Options', 'acf'));
             $custom = apply_filters('acf_register_options_page', array());
             if (!empty($custom)) {
                 $choices = array();
                 foreach ($custom as $c) {
                     $choices[$c['slug']] = $c['title'];
                 }
             }
             break;
         case "taxonomy":
             $choices = $this->parent->get_taxonomies_for_select(array('simple_value' => true));
             $optgroup = true;
             break;
         case "ef_taxonomy":
             $choices = array('all' => __('All', 'acf'));
             $taxonomies = get_taxonomies(array('public' => true), 'objects');
             foreach ($taxonomies as $taxonomy) {
                 $choices[$taxonomy->name] = $taxonomy->labels->name;
             }
             // unset post_format (why is this a public taxonomy?)
             if (isset($choices['post_format'])) {
                 unset($choices['post_format']);
             }
             break;
         case "ef_user":
             global $wp_roles;
             $choices = array_merge(array('all' => __('All', 'acf')), $wp_roles->get_names());
             break;
         case "ef_media":
             $choices = array('all' => __('All', 'acf'));
             break;
     }
     $this->parent->create_field(array('type' => 'select', 'name' => 'location[rules][' . $options['key'] . '][value]', 'value' => $options['value'], 'choices' => $choices, 'optgroup' => $optgroup));
     // ajax?
     if (isset($_POST['action']) && $_POST['action'] == "acf_location") {
         die;
     }
 }
    /**
     * Outputs the hidden row displayed when inline editing
     *
     * @since 3.1.0
     */
    function inline_edit()
    {
        global $mode;
        $screen = $this->screen;
        $post = get_default_post_to_edit($screen->post_type);
        $post_type_object = get_post_type_object($screen->post_type);
        $taxonomy_names = get_object_taxonomies($screen->post_type);
        $hierarchical_taxonomies = array();
        $flat_taxonomies = array();
        foreach ($taxonomy_names as $taxonomy_name) {
            $taxonomy = get_taxonomy($taxonomy_name);
            if (!$taxonomy->show_ui) {
                continue;
            }
            if ($taxonomy->hierarchical) {
                $hierarchical_taxonomies[] = $taxonomy;
            } else {
                $flat_taxonomies[] = $taxonomy;
            }
        }
        $m = isset($mode) && 'excerpt' == $mode ? 'excerpt' : 'list';
        $can_publish = current_user_can($post_type_object->cap->publish_posts);
        $core_columns = array('cb' => true, 'date' => true, 'title' => true, 'categories' => true, 'tags' => true, 'comments' => true, 'author' => true);
        ?>

	<form method="get" action=""><table style="display: none"><tbody id="inlineedit">
		<?php 
        $hclass = count($hierarchical_taxonomies) ? 'post' : 'page';
        $bulk = 0;
        while ($bulk < 2) {
            ?>

		<tr id="<?php 
            echo $bulk ? 'bulk-edit' : 'inline-edit';
            ?>
" class="inline-edit-row inline-edit-row-<?php 
            echo "{$hclass} inline-edit-" . $screen->post_type;
            echo $bulk ? " bulk-edit-row bulk-edit-row-{$hclass} bulk-edit-{$screen->post_type}" : " quick-edit-row quick-edit-row-{$hclass} inline-edit-{$screen->post_type}";
            ?>
" style="display: none"><td colspan="<?php 
            echo $this->get_column_count();
            ?>
" class="colspanchange">

		<fieldset class="inline-edit-col-left"><div class="inline-edit-col">
			<h4><?php 
            echo $bulk ? __('Bulk Edit') : __('Quick Edit');
            ?>
</h4>
	<?php 
            if (post_type_supports($screen->post_type, 'title')) {
                if ($bulk) {
                    ?>
			<div id="bulk-title-div">
				<div id="bulk-titles"></div>
			</div>

	<?php 
                } else {
                    // $bulk
                    ?>

			<label>
				<span class="title"><?php 
                    _e('Title');
                    ?>
</span>
				<span class="input-text-wrap"><input type="text" name="post_title" class="ptitle" value="" /></span>
			</label>

			<label>
				<span class="title"><?php 
                    _e('Slug');
                    ?>
</span>
				<span class="input-text-wrap"><input type="text" name="post_name" value="" /></span>
			</label>

	<?php 
                }
                // $bulk
            }
            // post_type_supports title
            ?>

	<?php 
            if (!$bulk) {
                ?>
			<label><span class="title"><?php 
                _e('Date');
                ?>
</span></label>
			<div class="inline-edit-date">
				<?php 
                touch_time(1, 1, 0, 1);
                ?>
			</div>
			<br class="clear" />
	<?php 
            }
            // $bulk
            if (post_type_supports($screen->post_type, 'author')) {
                $authors_dropdown = '';
                if (is_super_admin() || current_user_can($post_type_object->cap->edit_others_posts)) {
                    $users_opt = array('hide_if_only_one_author' => false, 'who' => 'authors', 'name' => 'post_author', 'class' => 'authors', 'multi' => 1, 'echo' => 0);
                    if ($bulk) {
                        $users_opt['show_option_none'] = __('&mdash; No Change &mdash;');
                    }
                    if ($authors = wp_dropdown_users($users_opt)) {
                        $authors_dropdown = '<label class="inline-edit-author">';
                        $authors_dropdown .= '<span class="title">' . __('Author') . '</span>';
                        $authors_dropdown .= $authors;
                        $authors_dropdown .= '</label>';
                    }
                }
                // authors
                ?>

	<?php 
                if (!$bulk) {
                    echo $authors_dropdown;
                }
            }
            // post_type_supports author
            if (!$bulk && $can_publish) {
                ?>

			<div class="inline-edit-group">
				<label class="alignleft">
					<span class="title"><?php 
                _e('Password');
                ?>
</span>
					<span class="input-text-wrap"><input type="text" name="post_password" class="inline-edit-password-input" value="" /></span>
				</label>

				<em style="margin:5px 10px 0 0" class="alignleft">
					<?php 
                /* translators: Between password field and private checkbox on post quick edit interface */
                echo __('&ndash;OR&ndash;');
                ?>
				</em>
				<label class="alignleft inline-edit-private">
					<input type="checkbox" name="keep_private" value="private" />
					<span class="checkbox-title"><?php 
                echo __('Private');
                ?>
</span>
				</label>
			</div>

	<?php 
            }
            ?>

		</div></fieldset>

	<?php 
            if (count($hierarchical_taxonomies) && !$bulk) {
                ?>

		<fieldset class="inline-edit-col-center inline-edit-categories"><div class="inline-edit-col">

	<?php 
                foreach ($hierarchical_taxonomies as $taxonomy) {
                    ?>

			<span class="title inline-edit-categories-label"><?php 
                    echo esc_html($taxonomy->labels->name);
                    ?>
</span>
			<input type="hidden" name="<?php 
                    echo $taxonomy->name == 'category' ? 'post_category[]' : 'tax_input[' . esc_attr($taxonomy->name) . '][]';
                    ?>
" value="0" />
			<ul class="cat-checklist <?php 
                    echo esc_attr($taxonomy->name);
                    ?>
-checklist">
				<?php 
                    wp_terms_checklist(null, array('taxonomy' => $taxonomy->name));
                    ?>
			</ul>

	<?php 
                }
                //$hierarchical_taxonomies as $taxonomy
                ?>

		</div></fieldset>

	<?php 
            }
            // count( $hierarchical_taxonomies ) && !$bulk
            ?>

		<fieldset class="inline-edit-col-right"><div class="inline-edit-col">

	<?php 
            if (post_type_supports($screen->post_type, 'author') && $bulk) {
                echo $authors_dropdown;
            }
            if (post_type_supports($screen->post_type, 'page-attributes')) {
                if ($post_type_object->hierarchical) {
                    ?>
			<label>
				<span class="title"><?php 
                    _e('Parent');
                    ?>
</span>
	<?php 
                    $dropdown_args = array('post_type' => $post_type_object->name, 'selected' => $post->post_parent, 'name' => 'post_parent', 'show_option_none' => __('Main Page (no parent)'), 'option_none_value' => 0, 'sort_column' => 'menu_order, post_title');
                    if ($bulk) {
                        $dropdown_args['show_option_no_change'] = __('&mdash; No Change &mdash;');
                    }
                    $dropdown_args = apply_filters('quick_edit_dropdown_pages_args', $dropdown_args);
                    wp_dropdown_pages($dropdown_args);
                    ?>
			</label>

	<?php 
                }
                // hierarchical
                if (!$bulk) {
                    ?>

			<label>
				<span class="title"><?php 
                    _e('Order');
                    ?>
</span>
				<span class="input-text-wrap"><input type="text" name="menu_order" class="inline-edit-menu-order-input" value="<?php 
                    echo $post->menu_order;
                    ?>
" /></span>
			</label>

	<?php 
                }
                // !$bulk
                if ('page' == $screen->post_type) {
                    ?>

			<label>
				<span class="title"><?php 
                    _e('Template');
                    ?>
</span>
				<select name="page_template">
	<?php 
                    if ($bulk) {
                        ?>
					<option value="-1"><?php 
                        _e('&mdash; No Change &mdash;');
                        ?>
</option>
	<?php 
                    }
                    // $bulk
                    ?>
					<option value="default"><?php 
                    _e('Default Template');
                    ?>
</option>
					<?php 
                    page_template_dropdown();
                    ?>
				</select>
			</label>

	<?php 
                }
                // page post_type
            }
            // page-attributes
            ?>

	<?php 
            if (count($flat_taxonomies) && !$bulk) {
                ?>

	<?php 
                foreach ($flat_taxonomies as $taxonomy) {
                    ?>
		<?php 
                    if (current_user_can($taxonomy->cap->assign_terms)) {
                        ?>
			<label class="inline-edit-tags">
				<span class="title"><?php 
                        echo esc_html($taxonomy->labels->name);
                        ?>
</span>
				<textarea cols="22" rows="1" name="tax_input[<?php 
                        echo esc_attr($taxonomy->name);
                        ?>
]" class="tax_input_<?php 
                        echo esc_attr($taxonomy->name);
                        ?>
"></textarea>
			</label>
		<?php 
                    }
                    ?>

	<?php 
                }
                //$flat_taxonomies as $taxonomy
                ?>

	<?php 
            }
            // count( $flat_taxonomies ) && !$bulk
            ?>

	<?php 
            if (post_type_supports($screen->post_type, 'comments') || post_type_supports($screen->post_type, 'trackbacks')) {
                if ($bulk) {
                    ?>

			<div class="inline-edit-group">
		<?php 
                    if (post_type_supports($screen->post_type, 'comments')) {
                        ?>
			<label class="alignleft">
				<span class="title"><?php 
                        _e('Comments');
                        ?>
</span>
				<select name="comment_status">
					<option value=""><?php 
                        _e('&mdash; No Change &mdash;');
                        ?>
</option>
					<option value="open"><?php 
                        _e('Allow');
                        ?>
</option>
					<option value="closed"><?php 
                        _e('Do not allow');
                        ?>
</option>
				</select>
			</label>
		<?php 
                    }
                    if (post_type_supports($screen->post_type, 'trackbacks')) {
                        ?>
			<label class="alignright">
				<span class="title"><?php 
                        _e('Pings');
                        ?>
</span>
				<select name="ping_status">
					<option value=""><?php 
                        _e('&mdash; No Change &mdash;');
                        ?>
</option>
					<option value="open"><?php 
                        _e('Allow');
                        ?>
</option>
					<option value="closed"><?php 
                        _e('Do not allow');
                        ?>
</option>
				</select>
			</label>
		<?php 
                    }
                    ?>
			</div>

	<?php 
                } else {
                    // $bulk
                    ?>

			<div class="inline-edit-group">
			<?php 
                    if (post_type_supports($screen->post_type, 'comments')) {
                        ?>
				<label class="alignleft">
					<input type="checkbox" name="comment_status" value="open" />
					<span class="checkbox-title"><?php 
                        _e('Allow Comments');
                        ?>
</span>
				</label>
			<?php 
                    }
                    if (post_type_supports($screen->post_type, 'trackbacks')) {
                        ?>
				<label class="alignleft">
					<input type="checkbox" name="ping_status" value="open" />
					<span class="checkbox-title"><?php 
                        _e('Allow Pings');
                        ?>
</span>
				</label>
			<?php 
                    }
                    ?>
			</div>

	<?php 
                }
                // $bulk
            }
            // post_type_supports comments or pings
            ?>

			<div class="inline-edit-group">
				<label class="inline-edit-status alignleft">
					<span class="title"><?php 
            _e('Status');
            ?>
</span>
					<select name="_status">
	<?php 
            if ($bulk) {
                ?>
						<option value="-1"><?php 
                _e('&mdash; No Change &mdash;');
                ?>
</option>
	<?php 
            }
            // $bulk
            ?>
					<?php 
            if ($can_publish) {
                // Contributors only get "Unpublished" and "Pending Review"
                ?>
						<option value="publish"><?php 
                _e('Published');
                ?>
</option>
						<option value="future"><?php 
                _e('Scheduled');
                ?>
</option>
	<?php 
                if ($bulk) {
                    ?>
						<option value="private"><?php 
                    _e('Private');
                    ?>
</option>
	<?php 
                }
                // $bulk
                ?>
					<?php 
            }
            ?>
						<option value="pending"><?php 
            _e('Pending Review');
            ?>
</option>
						<option value="draft"><?php 
            _e('Draft');
            ?>
</option>
					</select>
				</label>

	<?php 
            if ('post' == $screen->post_type && $can_publish && current_user_can($post_type_object->cap->edit_others_posts)) {
                ?>

	<?php 
                if ($bulk) {
                    ?>

				<label class="alignright">
					<span class="title"><?php 
                    _e('Sticky');
                    ?>
</span>
					<select name="sticky">
						<option value="-1"><?php 
                    _e('&mdash; No Change &mdash;');
                    ?>
</option>
						<option value="sticky"><?php 
                    _e('Sticky');
                    ?>
</option>
						<option value="unsticky"><?php 
                    _e('Not Sticky');
                    ?>
</option>
					</select>
				</label>

	<?php 
                } else {
                    // $bulk
                    ?>

				<label class="alignleft">
					<input type="checkbox" name="sticky" value="sticky" />
					<span class="checkbox-title"><?php 
                    _e('Make this post sticky');
                    ?>
</span>
				</label>

	<?php 
                }
                // $bulk
                ?>

	<?php 
            }
            // 'post' && $can_publish && current_user_can( 'edit_others_cap' )
            ?>

			</div>

	<?php 
            if ($bulk && post_type_supports($screen->post_type, 'post-formats')) {
                $all_post_formats = get_post_format_strings();
                ?>
		<label class="alignleft" for="post_format">
		<span class="title"><?php 
                _ex('Format', 'post format');
                ?>
</span>
		<select name="post_format">
			<option value="-1"><?php 
                _e('&mdash; No Change &mdash;');
                ?>
</option>
			<?php 
                foreach ($all_post_formats as $slug => $format) {
                    ?>
				<option value="<?php 
                    echo esc_attr($slug);
                    ?>
"><?php 
                    echo esc_html($format);
                    ?>
</option>
				<?php 
                }
                ?>
		</select></label>
	<?php 
            }
            ?>

		</div></fieldset>

	<?php 
            list($columns) = $this->get_column_info();
            foreach ($columns as $column_name => $column_display_name) {
                if (isset($core_columns[$column_name])) {
                    continue;
                }
                do_action($bulk ? 'bulk_edit_custom_box' : 'quick_edit_custom_box', $column_name, $screen->post_type);
            }
            ?>
		<p class="submit inline-edit-save">
			<a accesskey="c" href="#inline-edit" class="button-secondary cancel alignleft"><?php 
            _e('Cancel');
            ?>
</a>
			<?php 
            if (!$bulk) {
                wp_nonce_field('inlineeditnonce', '_inline_edit', false);
                ?>
				<a accesskey="s" href="#inline-edit" class="button-primary save alignright"><?php 
                _e('Update');
                ?>
</a>
				<span class="spinner"></span>
			<?php 
            } else {
                submit_button(__('Update'), 'button-primary alignright', 'bulk_edit', false, array('accesskey' => 's'));
            }
            ?>
			<input type="hidden" name="post_view" value="<?php 
            echo esc_attr($m);
            ?>
" />
			<input type="hidden" name="screen" value="<?php 
            echo esc_attr($screen->id);
            ?>
" />
			<?php 
            if (!$bulk && !post_type_supports($screen->post_type, 'author')) {
                ?>
				<input type="hidden" name="post_author" value="<?php 
                echo esc_attr($post->post_author);
                ?>
" />
			<?php 
            }
            ?>
			<span class="error" style="display:none"></span>
			<br class="clear" />
		</p>
		</td></tr>
	<?php 
            $bulk++;
        }
        ?>
		</tbody></table></form>
<?php 
    }
Esempio n. 10
0
 function ajax_render_location($options = array())
 {
     // defaults
     $defaults = array('group_id' => 0, 'rule_id' => 0, 'value' => null, 'param' => null);
     $is_ajax = false;
     if (isset($_POST['nonce']) && wp_verify_nonce($_POST['nonce'], 'acf_nonce')) {
         $is_ajax = true;
     }
     // Is AJAX call?
     if ($is_ajax) {
         $options = array_merge($defaults, $_POST);
     } else {
         $options = array_merge($defaults, $options);
     }
     // vars
     $choices = array();
     // some case's have the same outcome
     if ($options['param'] == "page_parent") {
         $options['param'] = "page";
     }
     switch ($options['param']) {
         case "post_type":
             // all post types except attachment
             $choices = apply_filters('acf/get_post_types', array(), array('attachment'));
             break;
         case "page":
             $post_type = 'page';
             $posts = get_posts(array('posts_per_page' => -1, 'post_type' => $post_type, 'orderby' => 'menu_order title', 'order' => 'ASC', 'post_status' => 'any', 'suppress_filters' => false, 'update_post_meta_cache' => false));
             if ($posts) {
                 // sort into hierachial order!
                 if (is_post_type_hierarchical($post_type)) {
                     $posts = get_page_children(0, $posts);
                 }
                 foreach ($posts as $page) {
                     $title = '';
                     $ancestors = get_ancestors($page->ID, 'page');
                     if ($ancestors) {
                         foreach ($ancestors as $a) {
                             $title .= '- ';
                         }
                     }
                     $title .= apply_filters('the_title', $page->post_title, $page->ID);
                     // status
                     if ($page->post_status != "publish") {
                         $title .= " ({$page->post_status})";
                     }
                     $choices[$page->ID] = $title;
                 }
                 // foreach($pages as $page)
             }
             break;
         case "page_type":
             $choices = array('front_page' => __("Front Page", 'acf'), 'posts_page' => __("Posts Page", 'acf'), 'top_level' => __("Top Level Page (parent of 0)", 'acf'), 'parent' => __("Parent Page (has children)", 'acf'), 'child' => __("Child Page (has parent)", 'acf'));
             break;
         case "page_template":
             $choices = array('default' => __("Default Template", 'acf'));
             $templates = get_page_templates();
             foreach ($templates as $k => $v) {
                 $choices[$v] = $k;
             }
             break;
         case "post":
             $post_types = get_post_types();
             unset($post_types['page'], $post_types['attachment'], $post_types['revision'], $post_types['nav_menu_item'], $post_types['acf']);
             if ($post_types) {
                 foreach ($post_types as $post_type) {
                     $posts = get_posts(array('numberposts' => '-1', 'post_type' => $post_type, 'post_status' => array('publish', 'private', 'draft', 'inherit', 'future'), 'suppress_filters' => false));
                     if ($posts) {
                         $choices[$post_type] = array();
                         foreach ($posts as $post) {
                             $title = apply_filters('the_title', $post->post_title, $post->ID);
                             // status
                             if ($post->post_status != "publish") {
                                 $title .= " ({$post->post_status})";
                             }
                             $choices[$post_type][$post->ID] = $title;
                         }
                         // foreach($posts as $post)
                     }
                     // if( $posts )
                 }
                 // foreach( $post_types as $post_type )
             }
             // if( $post_types )
             break;
         case "post_category":
             $category_ids = get_all_category_ids();
             foreach ($category_ids as $cat_id) {
                 $cat_name = get_cat_name($cat_id);
                 $choices[$cat_id] = $cat_name;
             }
             break;
         case "post_format":
             $choices = get_post_format_strings();
             break;
         case "post_status":
             $choices = array('publish' => __('Publish', 'acf'), 'pending' => __('Pending Review', 'acf'), 'draft' => __('Draft', 'acf'), 'future' => __('Future', 'acf'), 'private' => __('Private', 'acf'), 'inherit' => __('Revision', 'acf'), 'trash' => __('Trash', 'acf'));
             break;
         case "user_type":
             global $wp_roles;
             $choices = $wp_roles->get_names();
             if (is_multisite()) {
                 $choices['super_admin'] = __('Super Admin', 'acf');
             }
             break;
         case "taxonomy":
             $choices = array();
             $simple_value = true;
             $choices = apply_filters('acf/get_taxonomies_for_select', $choices, $simple_value);
             break;
         case "ef_taxonomy":
             $choices = array('all' => __('All', 'acf'));
             $taxonomies = get_taxonomies(array('public' => true), 'objects');
             foreach ($taxonomies as $taxonomy) {
                 $choices[$taxonomy->name] = $taxonomy->labels->name;
             }
             // unset post_format (why is this a public taxonomy?)
             if (isset($choices['post_format'])) {
                 unset($choices['post_format']);
             }
             break;
         case "ef_user":
             global $wp_roles;
             $choices = array_merge(array('all' => __('All', 'acf')), $wp_roles->get_names());
             break;
         case "ef_media":
             $choices = array('all' => __('All', 'acf'));
             break;
     }
     // allow custom location rules
     $choices = apply_filters('acf/location/rule_values/' . $options['param'], $choices);
     // create field
     do_action('acf/create_field', array('type' => 'select', 'name' => 'location[' . $options['group_id'] . '][' . $options['rule_id'] . '][value]', 'value' => $options['value'], 'choices' => $choices));
     // ajax?
     if ($is_ajax) {
         die;
     }
 }
<ul class="clearfix">
	<li class="post-format-pad"><a title="<?php 
esc_attr_e('Standard', 'church-event');
?>
" href="<?php 
echo esc_attr(add_query_arg('format_filter', 'standard', home_url()));
?>
" class="standard"><?php 
echo do_shortcode('[icon name="' . WpvPostFormats::get_post_format_icon('standard') . '"]');
?>
</a></li>
	<?php 
$tooltip = empty($instance['tooltip']) ? __('View all %format posts', 'church-event') : esc_attr($instance['tooltip']);
foreach (get_post_format_strings() as $slug => $string) {
    if (get_post_format_link($slug)) {
        $post_format = get_term_by('slug', 'post-format-' . $slug, 'post_format');
        if ($post_format->count > 0) {
            echo '<li class="post-format-pad"><a title="' . esc_attr(str_replace('%format', $string, $tooltip)) . '" href="' . esc_attr(add_query_arg('format_filter', $slug, home_url())) . '" class="' . $slug . '">' . do_shortcode('[icon name="' . WpvPostFormats::get_post_format_icon($slug) . '"]') . '</a></li>';
        }
    }
}
?>
</ul>
 /**
  * Retrieves a list of post formats used by the site.
  *
  * @since 3.1.0
  *
  * @param array  $args {
  *     Method arguments. Note: arguments must be ordered as documented.
  *
  *     @type int    $blog_id (unused)
  *     @type string $username
  *     @type string $password
  * }
  * @return array|IXR_Error List of post formats, otherwise IXR_Error object.
  */
 public function wp_getPostFormats($args)
 {
     $this->escape($args);
     $username = $args[1];
     $password = $args[2];
     if (!($user = $this->login($username, $password))) {
         return $this->error;
     }
     if (!current_user_can('edit_posts')) {
         return new IXR_Error(403, __('You are not allowed access to details about this site.'));
     }
     /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
     do_action('xmlrpc_call', 'wp.getPostFormats');
     $formats = get_post_format_strings();
     // find out if they want a list of currently supports formats
     if (isset($args[3]) && is_array($args[3])) {
         if ($args[3]['show-supported']) {
             if (current_theme_supports('post-formats')) {
                 $supported = get_theme_support('post-formats');
                 $data = array();
                 $data['all'] = $formats;
                 $data['supported'] = $supported[0];
                 $formats = $data;
             }
         }
     }
     return $formats;
 }
 /**
  * Try to make a nice comment
  *
  * @param string $context the comment-content
  * @param string $contents the HTML of the source
  * @param string $target the target URL
  * @param string $source the source URL
  *
  * @return string the filtered content
  */
 public static function default_content_filter($content, $contents, $target, $source)
 {
     // get post format
     $post_ID = url_to_postid($target);
     $post_format = get_post_format($post_ID);
     // replace "standard" with "Article"
     if (!$post_format || 'standard' == $post_format) {
         $post_format = 'Article';
     } else {
         $post_formatstrings = get_post_format_strings();
         // get the "nice" name
         $post_format = $post_formatstrings[$post_format];
     }
     $host = parse_url($source, PHP_URL_HOST);
     // strip leading www, if any
     $host = preg_replace('/^www\\./', '', $host);
     // generate default text
     $content = sprintf(__('This %s was mentioned on <a href="%s">%s</a>', 'webmention'), $post_format, esc_url($source), $host);
     return $content;
 }
Esempio n. 14
0
 public static function page_selectors()
 {
     global $wp_post_types, $wp_taxonomies;
     $res = q2w3_include_obj::page_selectors();
     foreach ($wp_post_types as $post_type) {
         if (!in_array($post_type->name, q2w3_inc_manager::$restricted_post_types)) {
             $res += array($post_type->name . '_all' => __('All', q2w3_inc_manager::ID) . ' ' . $post_type->labels->name);
             $res += array('post_type_archive_' . $post_type->name => __('Archive', q2w3_inc_manager::ID) . ': ' . $post_type->labels->name);
             $selectors = self::select_post_type($post_type->name);
             if (!empty($selectors)) {
                 $res += $selectors;
             }
         }
     }
     foreach ($wp_taxonomies as $taxonomy) {
         if (!in_array($taxonomy->name, q2w3_inc_manager::$restricted_taxonomies)) {
             $res += array($taxonomy->name . '_all' => __('All', q2w3_inc_manager::ID) . ' ' . $taxonomy->labels->name);
             $selectors = self::select_taxonomy($taxonomy->name);
             if (!empty($selectors)) {
                 $res += $selectors;
             }
         }
     }
     $formats_orig = get_post_format_strings();
     foreach ($formats_orig as $fkey => $fname) {
         $res['post_format_' . $fkey] = __('PF', $plugin_id) . ': ' . $fname;
     }
     return $res;
 }
function get_post_format_slugs()
{
    $slugs = array_keys(get_post_format_strings());
    return array_combine($slugs, $slugs);
}
Esempio n. 16
0
			"id" : 123,
			"key" : "test_meta_key",
			"value" : "test_value",
		}
	},
	"meta": {
		"links": {
			"self": "https:\\/\\/public-api.wordpress.com\\/rest\\/v1\\/sites\\/30434183\\/posts\\/1270",
			"help": "https:\\/\\/public-api.wordpress.com\\/rest\\/v1\\/sites\\/30434183\\/posts\\/1270\\/help",
			"site": "https:\\/\\/public-api.wordpress.com\\/rest\\/v1\\/sites\\/30434183",
			"replies": "https:\\/\\/public-api.wordpress.com\\/rest\\/v1\\/sites\\/30434183\\/posts\\/1270\\/replies\\/",
			"likes": "https:\\/\\/public-api.wordpress.com\\/rest\\/v1\\/sites\\/30434183\\/posts\\/1270\\/likes\\/"
		}
	}
}'));
new WPCOM_JSON_API_Update_Post_Endpoint(array('description' => 'Edit a Post', 'group' => 'posts', 'stat' => 'posts:1:POST', 'method' => 'POST', 'path' => '/sites/%s/posts/%d', 'path_labels' => array('$site' => '(int|string) The site ID, The site domain', '$post_ID' => '(int) The post ID'), 'request_format' => array('date' => "(ISO 8601 datetime) The post's creation time.", 'title' => '(HTML) The post title.', 'content' => '(HTML) The post content.', 'excerpt' => '(HTML) An optional post excerpt.', 'slug' => '(string) The name (slug) for the post, used in URLs.', 'author' => '(string) The username or ID for the user to assign the post to.', 'publicize' => '(array|bool) True or false if the post be publicized to external services. An array of services if we only want to publicize to a select few. Defaults to true.', 'publicize_message' => '(string) Custom message to be publicized to external services.', 'status' => array('publish' => 'Publish the post.', 'private' => 'Privately publish the post.', 'draft' => 'Save the post as a draft.', 'pending' => 'Mark the post as pending editorial approval.'), 'sticky' => '(bool) Mark the post as sticky?', 'password' => '(string) The plaintext password protecting the post, or, more likely, the empty string if the post is not password protected.', 'parent' => "(int) The post ID of the new post's parent.", 'categories' => "(string) Comma separated list of categories (name or id)", 'tags' => "(string) Comma separated list of tags (name or id)", 'format' => get_post_format_strings(), 'comments_open' => '(bool) Should the post be open to comments?', 'pings_open' => '(bool) Should the post be open to comments?', 'likes_enabled' => "(bool) Should the post be open to likes?", 'sharing_enabled' => "(bool) Should sharing buttons show on this post?", 'gplusauthorship_enabled' => "(bool) Should a Google+ account be associated with this post?", 'featured_image' => "(string) The post ID of an existing attachment to set as the featured image. Pass an empty string to delete the existing image.", 'media' => "(media) An array of images to attach to the post. To upload media, the entire request should be multipart/form-data encoded.  Multiple media items will be displayed in a gallery.  Accepts images (image/gif, image/jpeg, image/png) only.<br /><br /><strong>Example</strong>:<br />" . "<code>curl \\<br />--form 'title=Image' \\<br />--form 'media[]=@/path/to/file.jpg' \\<br />-H 'Authorization: BEARER your-token' \\<br />'https://public-api.wordpress.com/rest/v1/sites/123/posts/new'</code>", 'media_urls' => "(array) An array of URLs for images to attach to the post. Sideloads the media in for the post.", 'metadata' => "(array) Array of metadata objects containing the following properties: `key` (metadata key), `id` (meta ID), `previous_value` (if set, the action will only occur for the provided previous value), `value` (the new value to set the meta to), `operation` (the operation to perform: `update` or `add`; defaults to `update`). All unprotected meta keys are available by default for read requests. Both unprotected and protected meta keys are available for authenticated requests with proper capabilities. Protected meta keys can be made available with the <code>rest_api_allowed_public_metadata</code> filter."), 'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/30434183/posts/1222/', 'example_request_data' => array('headers' => array('authorization' => 'Bearer YOUR_API_TOKEN'), 'body' => array('title' => 'Hello World (Again)', 'content' => 'Hello. I am an edited post. I was edited by the API', 'tags' => 'tests', 'categories' => 'API')), 'example_response' => '
{
	"ID": 1222,
	"author": {
		"ID": 422,
		"email": false,
		"name": "Justin Shreve",
		"URL": "http:\\/\\/justin.wordpress.com",
		"avatar_URL": "http:\\/\\/1.gravatar.com\\/avatar\\/9ea5b460afb2859968095ad3afe4804b?s=96&d=identicon&r=G",
		"profile_URL": "http:\\/\\/en.gravatar.com\\/justin"
	},
	"date": "2012-04-11T15:53:52+00:00",
	"modified": "2012-04-11T19:44:35+00:00",
	"title": "Hello World (Again)",
	"URL": "http:\\/\\/opossumapi.wordpress.com\\/2012\\/04\\/11\\/hello-world-2\\/",
	"short_URL": "http:\\/\\/wp.me\\/p23HjV-jI",
 /**
  * Creates an array of ElasticSearch filters based on the post_id and args.
  *
  * @param int $post_id
  * @param array $args
  * @uses apply_filters, get_post_types, get_post_format_strings
  * @return array
  */
 protected function _get_es_filters_from_args($post_id, array $args)
 {
     $filters = array();
     $args['has_terms'] = apply_filters('jetpack_relatedposts_filter_has_terms', $args['has_terms'], $post_id);
     if (!empty($args['has_terms'])) {
         foreach ((array) $args['has_terms'] as $term) {
             if (mb_strlen($term->taxonomy)) {
                 switch ($term->taxonomy) {
                     case 'post_tag':
                         $tax_fld = 'tag.slug';
                         break;
                     case 'category':
                         $tax_fld = 'category.slug';
                         break;
                     default:
                         $tax_fld = 'taxonomy.' . $term->taxonomy . '.slug';
                         break;
                 }
                 $filters[] = array('term' => array($tax_fld => $term->slug));
             }
         }
     }
     $args['post_type'] = apply_filters('jetpack_relatedposts_filter_post_type', $args['post_type'], $post_id);
     $valid_post_types = get_post_types();
     if (is_array($args['post_type'])) {
         $sanitized_post_types = array();
         foreach ($args['post_type'] as $pt) {
             if (in_array($pt, $valid_post_types)) {
                 $sanitized_post_types[] = $pt;
             }
         }
         if (!empty($sanitized_post_types)) {
             $filters[] = array('terms' => array('post_type' => $sanitized_post_types));
         }
     } else {
         if (in_array($args['post_type'], $valid_post_types) && 'all' != $args['post_type']) {
             $filters[] = array('term' => array('post_type' => $args['post_type']));
         }
     }
     $args['post_formats'] = apply_filters('jetpack_relatedposts_filter_post_formats', $args['post_formats'], $post_id);
     $valid_post_formats = get_post_format_strings();
     $sanitized_post_formats = array();
     foreach ($args['post_formats'] as $pf) {
         if (array_key_exists($pf, $valid_post_formats)) {
             $sanitized_post_formats[] = $pf;
         }
     }
     if (!empty($sanitized_post_formats)) {
         $filters[] = array('terms' => array('post_format' => $sanitized_post_formats));
     }
     $args['date_range'] = apply_filters('jetpack_relatedposts_filter_date_range', $args['date_range'], $post_id);
     if (is_array($args['date_range']) && !empty($args['date_range'])) {
         $args['date_range'] = array_map('intval', $args['date_range']);
         if (!empty($args['date_range']['from']) && !empty($args['date_range']['to'])) {
             $filters[] = array('range' => array('date_gmt' => $this->_get_coalesced_range($args['date_range'])));
         }
     }
     $args['exclude_post_ids'] = apply_filters('jetpack_relatedposts_filter_exclude_post_ids', $args['exclude_post_ids'], $post_id);
     if (!empty($args['exclude_post_ids']) && is_array($args['exclude_post_ids'])) {
         foreach ($args['exclude_post_ids'] as $exclude_post_id) {
             $exclude_post_id = (int) $exclude_post_id;
             if ($exclude_post_id > 0) {
                 $filters[] = array('not' => array('term' => array('post_id' => $exclude_post_id)));
             }
         }
     }
     return $filters;
 }
 public static function comment_text_excerpt($text, $comment = null, $args = array())
 {
     // only change text for pingbacks/trackbacks/webmentions
     if (!$comment || '' === $comment->comment_type || !get_comment_meta($comment->comment_ID, 'semantic_linkbacks_canonical', true)) {
         return $text;
     }
     // check comment type
     $comment_type = get_comment_meta($comment->comment_ID, 'semantic_linkbacks_type', true);
     if (!$comment_type || !in_array($comment_type, array_keys(SemanticLinkbacksPlugin::get_comment_type_strings()))) {
         $comment_type = 'mention';
     }
     $_kind = get_the_terms($comment->comment_post_ID, 'kind');
     if (!empty($_kind)) {
         $kind = array_shift($_kind);
         $kindstrings = self::get_strings();
         $post_format = $kindstrings[$kind->slug];
     } else {
         $post_format = get_post_format($comment->comment_post_ID);
         // replace "standard" with "Article"
         if (!$post_format || 'standard' === $post_format) {
             $post_format = 'Article';
         } else {
             $post_formatstrings = get_post_format_strings();
             // get the "nice" name
             $post_format = $post_formatstrings[$post_format];
         }
     }
     // generate the verb, for example "mentioned" or "liked"
     $comment_type_excerpts = SemanticLinkbacksPlugin::get_comment_type_excerpts();
     // get URL canonical url...
     $url = get_comment_meta($comment->comment_ID, 'semantic_linkbacks_canonical', true);
     // ...or fall back to source
     if (!$url) {
         $url = get_comment_meta($comment->comment_ID, 'semantic_linkbacks_source', true);
     }
     // parse host
     $host = parse_url($url, PHP_URL_HOST);
     // strip leading www, if any
     $host = preg_replace('/^www\\./', '', $host);
     // generate output
     $text = sprintf($comment_type_excerpts[$comment_type], get_comment_author_link($comment->comment_ID), 'this ' . $post_format, $url, $host);
     return apply_filters('semantic_linkbacks_excerpt', $text);
 }
Esempio n. 19
0
function ozh_ta_setting($setting)
{
    // get setting value
    global $ozh_ta;
    $value = $ozh_ta[$setting];
    // echo the field
    switch ($setting) {
        case 'screen_name':
        case 'cons_key':
        case 'cons_secret':
            $value = esc_attr($value);
            echo "<input id='{$setting}' name='ozh_ta[{$setting}]' type='text' value='{$value}' />";
            break;
            $value = esc_attr($value);
            echo "<input id='{$setting}' name='ozh_ta[{$setting}]' type='text' value='{$value}' />";
            break;
        case 'refresh_interval':
            $options = array('300' => 'every 5 minutes', '900' => 'every 15 minutes', '3600' => 'hourly', '43200' => 'twice daily', '86400' => 'daily');
            $value = absint($value);
            echo "<select id='{$setting}' name='ozh_ta[{$setting}]'>\n";
            foreach ($options as $option => $desc) {
                echo "<option value='{$option}' " . selected($option, $value, false) . ">{$desc}</option>\n";
            }
            echo "</select>\n";
            echo "<br/>How often you want WordPress to check for new tweets and archive them.<br/>Ideally, select a frequency corresponding to 10 or 15 tweets.";
            break;
        case 'post_category':
            $value = absint($value);
            wp_dropdown_categories(array('hide_empty' => 0, 'name' => "ozh_ta[{$setting}]", 'orderby' => 'name', 'selected' => $value, 'hierarchical' => true));
            echo "<br/>Posts will be filed into this category.";
            break;
        case 'post_format':
            $options = get_post_format_strings();
            $value = array_key_exists($value, $options) ? $value : 'standard';
            echo "<select class='toggler' id='{$setting}' name='ozh_ta[{$setting}]'>\n";
            foreach ($options as $option => $desc) {
                echo "<option value='{$option}' " . selected($option, $value, false) . ">{$desc}</option>\n";
            }
            echo "</select>\n";
            echo "<br/>Posts will be assigned this post format.";
            break;
        case 'post_author':
            global $wpdb;
            $value = absint($value);
            $logins = $wpdb->get_results("SELECT ID as 'option', user_login as 'desc' FROM {$wpdb->users} ORDER BY user_login ASC");
            echo "<select id='{$setting}' name='ozh_ta[{$setting}]'>\n";
            foreach ($logins as $login) {
                echo "<option value='{$login->option}' " . selected($login->option, $value, false) . ">{$login->desc}</option>\n";
            }
            echo "</select>\n";
            echo "<br/>Tweets will be assigned to this author.";
            break;
        case 'link_usernames':
            $options = array('no' => 'No', 'yes' => 'Yes');
            $value = $value == 'yes' ? 'yes' : 'no';
            echo "<select class='toggler' id='{$setting}' name='ozh_ta[{$setting}]'>\n";
            foreach ($options as $option => $desc) {
                echo "<option value='{$option}' " . selected($option, $value, false) . ">{$desc}</option>\n";
            }
            echo "</select>\n";
            echo "<br/>Example: \"<span id='helper_link_usernames' class='tweet_sample'>Thank you\n\t\t<span id='toggle_link_usernames_no' class='toggle_link_usernames' style='display:" . ($value == 'no' ? 'inline' : 'none') . "'>@ozh</span>\n\t\t<span id='toggle_link_usernames_yes' class='toggle_link_usernames' style='display:" . ($value == 'yes' ? 'inline' : 'none') . "'>@<a href='https://twitter.com/ozh'>ozh</a></span>\n\t\tfor the #WordPress plugins!</span>\"";
            break;
        case 'un_tco':
            $options = array('no' => 'No', 'yes' => 'Yes');
            $value = $value == 'yes' ? 'yes' : 'no';
            echo "<select class='toggler' id='{$setting}' name='ozh_ta[{$setting}]'>\n";
            foreach ($options as $option => $desc) {
                echo "<option value='{$option}' " . selected($option, $value, false) . ">{$desc}</option>\n";
            }
            echo "</select>\n";
            echo "<br/>Example: \"<span id='helper_un_tco' class='tweet_sample fade-303060 fade'>Wow super site \n\t\t<span id='toggle_un_tco_no' class='toggle_un_tco' style='display:" . ($value == 'no' ? 'inline' : 'none') . "'><a href='http://t.co/JeIYgZHB6o'>t.co/JeIYgZHB6o</a></span>\n\t\t<span id='toggle_un_tco_yes' class='toggle_un_tco' style='display:" . ($value == 'yes' ? 'inline' : 'none') . "'><a href='http://ozh.org/'>ozh.org</a></span>\n\t\t! Check it out!</span>\"";
            break;
        case 'embed_images':
            $options = array('no' => 'No', 'yes' => 'Yes');
            $value = $value == 'yes' ? 'yes' : 'no';
            echo "<select class='toggler' id='{$setting}' name='ozh_ta[{$setting}]'>\n";
            foreach ($options as $option => $desc) {
                echo "<option value='{$option}' " . selected($option, $value, false) . ">{$desc}</option>\n";
            }
            echo "</select>\n";
            echo "<br/><span id='helper_embed_images' class='tweet_sample fade-303060 fade'>\n\t\t<span id='toggle_embed_images_no' class='toggle_embed_images' style='display:" . ($value == 'no' ? 'inline' : 'none') . "'>Just display a link to the image</span>\n\t\t<span id='toggle_embed_images_yes' class='toggle_embed_images' style='display:" . ($value == 'yes' ? 'inline' : 'none') . "'>Display a link and an &lt;img> after the text</span>\n\t\t</span>";
            break;
        case 'link_hashtags':
            $options = array('no' => 'No', 'twitter' => 'Yes, pointing to Twitter search', 'local' => 'Yes, pointing to blog tag links here');
            switch ($value) {
                case 'local':
                case 'twitter':
                case 'no':
                    $value = $value;
                    break;
                default:
                    $value = 'no';
            }
            echo "<select class='toggler' id='{$setting}' name='ozh_ta[{$setting}]'>\n";
            foreach ($options as $option => $desc) {
                echo "<option value='{$option}' " . selected($option, $value, false) . ">{$desc}</option>\n";
            }
            echo "</select>\n";
            echo "<br/>Example: \"<span id='helper_link_hashtags' class='tweet_sample fade-303060 fade'>Thank you @ozh for the\n\t\t<span id='toggle_link_hashtags_no' class='toggle_link_hashtags' style='display:" . ($value == 'no' ? 'inline' : 'none') . "'>#WordPress</span>\n\t\t<span id='toggle_link_hashtags_twitter' class='toggle_link_hashtags' style='display:" . ($value == 'twitter' ? 'inline' : 'none') . "'><a href='http://search.twitter.com/search?q=%23WordPress'>#WordPress</a></span>\n\t\t<span id='toggle_link_hashtags_local' class='toggle_link_hashtags' style='display:" . ($value == 'local' ? 'inline' : 'none') . "'><a href='" . ozh_ta_get_tag_link('wordpress') . "'>#WordPress</a></span>\n\t\tplugins!</span>\"";
            break;
        case 'add_hash_as_tags':
            $options = array('no' => 'No', 'yes' => 'Yes');
            $value = $value == 'yes' ? 'yes' : 'no';
            echo "<select id='{$setting}' name='ozh_ta[{$setting}]'>\n";
            foreach ($options as $option => $desc) {
                echo "<option value='{$option}' " . selected($option, $value, false) . ">{$desc}</option>\n";
            }
            echo "</select>\n";
            echo "<br/>If selected, tags in WordPress will be created with each #hashtags.";
            break;
    }
}
Esempio n. 20
0
function sp_ev_settings_page()
{
    // activate cron hook if not active
    sp_ev_activation();
    wp_enqueue_script('jquery');
    ?>
    <form id="delete_author" method="post" action="<?php 
    echo $_SERVER["REQUEST_URI"];
    ?>
" style="display: none">
        <input type="hidden" name="external_videos" value="Y" />
        <input type="hidden" name="action" value="delete_author" />
        <input type="hidden" name="host_id" />
        <input type="hidden" name="author_id" />
    </form>

    <script type="text/javascript">
        function delete_author(host_id, author_id) {
          jQuery('#delete_author [name="host_id"]').val(host_id);
          jQuery('#delete_author [name="author_id"]').val(author_id);
          var confirmtext = <?php 
    echo '"' . sprintf(__('Are you sure you want to remove %s on %s?', 'external-videos'), '"+ author_id +"', '"+ host_id +"') . '"';
    ?>
;
          if (!confirm(confirmtext)) {
              return false;
          }
          jQuery('#delete_author').submit();
        }
    </script>
 
    <div class="wrap">
        <h2><?php 
    _e('External Videos Settings', 'external-videos');
    ?>
</h2>
    <?php 
    $VIDEO_HOSTS = array('youtube' => 'YouTube', 'vimeo' => 'Vimeo', 'dotsub' => 'DotSub', 'wistia' => 'Wistia');
    $raw_options = get_option('sp_external_videos_options');
    $options = $raw_options == "" ? array('version' => 1, 'authors' => array(), 'rss' => false, 'delete' => true) : $raw_options;
    // clean up entered data from surplus white space
    $_POST['author_id'] = trim(sanitize_text_field($_POST['author_id']));
    $_POST['secret_key'] = trim(sanitize_text_field($_POST['secret_key']));
    $_POST['developer_key'] = trim(sanitize_text_field($_POST['developer_key']));
    if ($_POST['external_videos'] == 'Y') {
        if ($_POST['action'] == 'add_author') {
            if (!array_key_exists($_POST['host_id'], $VIDEO_HOSTS)) {
                ?>
<div class="error"><p><strong><?php 
                echo __('Invalid video host.', 'external-videos');
                ?>
</strong></p></div><?php 
            } elseif (sp_ev_local_author_exists($_POST['host_id'], $_POST['author_id'], $options['authors'])) {
                ?>
<div class="error"><p><strong><?php 
                echo __('Author already exists.', 'external-videos');
                ?>
</strong></p></div><?php 
            } elseif (!sp_ev_authorization_exists($_POST['host_id'], $_POST['developer_key'], $_POST['secret_key'])) {
                ?>
<div class="error"><p><strong><?php 
                echo __('Missing developer key.', 'external-videos');
                ?>
</strong></p></div><?php 
            } elseif (!sp_ev_remote_author_exists($_POST['host_id'], $_POST['author_id'], $_POST['developer_key'])) {
                ?>
<div class="error"><p><strong><?php 
                echo __('Invalid author - check spelling.', 'external-videos');
                ?>
</strong></p></div><?php 
            } else {
                $options['authors'][] = array('host_id' => $_POST['host_id'], 'author_id' => $_POST['author_id'], 'developer_key' => $_POST['developer_key'], 'secret_key' => $_POST['secret_key'], 'ev_author' => $_POST['user'], 'ev_category' => $_POST['post_category'], 'ev_post_format' => $_POST['post_format'], 'ev_post_status' => $_POST['post_status']);
                update_option('sp_external_videos_options', $options);
                ?>
<div class="updated"><p><strong><?php 
                echo __('Added author.', 'external-videos');
                ?>
</strong></p></div><?php 
            }
        } elseif ($_POST['action'] == 'delete_author') {
            if (!sp_ev_local_author_exists($_POST['host_id'], $_POST['author_id'], $options['authors'])) {
                ?>
<div class="error"><p><strong><?php 
                echo __("Can't delete an author that doesn't exist.", 'external-videos');
                ?>
</strong></p></div><?php 
            } else {
                foreach ($options['authors'] as $key => $author) {
                    if ($author['host_id'] == $_POST['host_id'] && $author['author_id'] == $_POST['author_id']) {
                        unset($options['authors'][$key]);
                    }
                }
                $options['authors'] = array_values($options['authors']);
                // also remove the author's videos from the posts table
                $del_videos = 0;
                $author_posts = new WP_Query(array('post_type' => 'external-videos', 'meta_key' => 'author_id', 'meta_value' => $_POST['author_id'], 'nopaging' => 1));
                while ($author_posts->have_posts()) {
                    $query_video = $author_posts->next_post();
                    $host = get_post_meta($query_video->ID, 'host_id', true);
                    if ($host == $_POST['host_id']) {
                        $post = get_post($query_video->ID);
                        $post->post_status = 'trash';
                        wp_update_post($post);
                        $del_videos += 1;
                    }
                }
                update_option('sp_external_videos_options', $options);
                unset($_POST['host_id'], $_POST['author_id']);
                ?>
<div class="updated"><p><strong><?php 
                printf(__('Deleted author and moved its %d video to trash.', 'Deleted author and its %d videos to trash.', $del_videos, 'external-videos'), $del_videos);
                ?>
</strong></p></div><?php 
            }
        } elseif ($_POST['action'] == 'sp_ev_update_videos') {
            $num_videos = sp_ev_update_videos($options['authors'], $options['delete']);
            ?>
<div class="updated"><p><strong><?php 
            printf(__('Found %d video.', 'Found %d videos.', $num_videos, 'external-videos'), $num_videos);
            ?>
</strong></p></div><?php 
        } elseif ($_POST['action'] == 'sp_ev_delete_videos') {
            $num_videos = sp_ev_delete_videos();
            ?>
<div class="deleted"><p><strong><?php 
            printf(__('Moved %d video into trash.', 'Moved %d videos into trash.', $num_videos, 'external-videos'), $num_videos);
            ?>
</strong></p></div><?php 
        } elseif ($_POST['action'] == 'ev_settings') {
            ?>
<div class="updated"><p><strong><?php 
            if ($_POST['ev-rss'] == "rss") {
                _e('Video pages will appear in RSS feed.', 'external-videos');
                $options['rss'] = true;
            } else {
                _e('Video pages will not appear in RSS feed.', 'external-videos');
                $options['rss'] = false;
            }
            ?>
<br/><?php 
            if ($_POST['ev-delete'] == "delete") {
                _e('Externally removed videos will be trashed.', 'external-videos');
                $options['delete'] = true;
            } else {
                _e('Externally removed videos will be kept.', 'external-videos');
                $options['delete'] = false;
            }
            update_option('sp_external_videos_options', $options);
            ?>
</strong></p></div><?php 
        }
    }
    ?>
    <h3><?php 
    _e('Authors', 'external-videos');
    ?>
</h3>
    <?php 
    foreach ($options['authors'] as $author) {
        echo sprintf(__('%1$s at %2$s', 'external-videos'), $author['author_id'], $VIDEO_HOSTS[$author['host_id']]) . " (<a href=\"#\" onclick=\"delete_author('" . $author['host_id'] . "', '" . $author['author_id'] . "');\">" . __('Delete') . "</a>) <br />\n";
    }
    ?>

    <h3><?php 
    _e('Add Publishers', 'external-videos');
    ?>
</h3>
    <form method="post" action="<?php 
    echo $_SERVER["REQUEST_URI"];
    ?>
">
        <input type="hidden" name="external_videos" value="Y" />
        <input type="hidden" name="action" value="add_author" />
        <p>
            <?php 
    _e('Video Host:', 'external-videos');
    ?>
            <select name="host_id">
            <?php 
    foreach ($VIDEO_HOSTS as $key => $value) {
        echo "<option value=\"{$key}\">{$value}";
    }
    ?>
            </select>
        <p>
            <?php 
    _e('Publisher ID:', 'external-videos');
    ?>
            <input type="text" name="author_id" value="<?php 
    echo sanitize_text_field($_POST['author_id']);
    ?>
"/>
            <?php 
    _e('(the identifier at the end of the URL; for wistia: domain prefix)', 'external-videos');
    ?>
        <p>
            <?php 
    _e('Developer Key:', 'external-videos');
    ?>
            <input type="text" name="developer_key" value="<?php 
    echo sanitize_text_field($_POST['developer_key']);
    ?>
"/>
            <?php 
    _e('(required for Vimeo/Wistia, leave empty otherwise)', 'external-videos');
    ?>
        <p>
            <?php 
    _e('Secret Key:', 'external-videos');
    ?>
            <input type="text" name="secret_key" value="<?php 
    echo sanitize_text_field($_POST['secret_key']);
    ?>
"/>
            <?php 
    _e('(required for Vimeo, leave empty otherwise)', 'external-videos');
    ?>
        </p>
        <p>
          <?php 
    _e('Default WP User', 'external-videos');
    ?>
          <?php 
    wp_dropdown_users();
    ?>
        </p>
        <p>
            <?php 
    _e('Default Post Category');
    ?>
            <?php 
    $selected_cats = array(get_cat_ID('External Videos', 'external-videos'));
    ?>
            <ul style="padding-left:20px;">
            <?php 
    wp_category_checklist(0, 0, $selected_cats, false, null, true);
    ?>
            </ul>
        </p>
        <p>
            <?php 
    _e('Default Post Format');
    ?>
            <?php 
    $post_formats = get_post_format_strings();
    unset($post_formats['video']);
    ?>
            <select name="post_format" id="ev_post_format">
              <option value="video"><?php 
    echo get_post_format_string('video');
    ?>
</option>
            <?php 
    foreach ($post_formats as $format_slug => $format_name) {
        ?>
              <option<?php 
        selected(get_option('post_format'), $format_slug);
        ?>
 value="<?php 
        echo esc_attr($format_slug);
        ?>
"><?php 
        echo esc_html($format_name);
        ?>
</option>
            <?php 
    }
    ?>
            </select>
        </p>
        <p>
          <?php 
    _e('Set Post Status', 'external-videos');
    ?>
          <select name='post_status' id='ev_post_status'>
            <option value='publish' selected><?php 
    _e('Published');
    ?>
</option>
            <option value='pending'><?php 
    _e('Pending Review');
    ?>
</option>
            <option value='draft'><?php 
    _e('Draft');
    ?>
</option>
            <option value='private'><?php 
    _e('Privately Published');
    ?>
</option>
            <option value='future'><?php 
    _e('Scheduled');
    ?>
</option>
          </select>
        </p>
        <p class="submit">
            <input type="submit" name="Submit" value="<?php 
    _e('Add new author', 'external-videos');
    ?>
" />
        </p>
    </form>

    <h3><?php 
    _e('Plugin Settings', 'external-videos');
    ?>
</h3>
    <form method="post" action="<?php 
    echo $_SERVER["REQUEST_URI"];
    ?>
">
      <input type="hidden" name="external_videos" value="Y" />
      <input type="hidden" name="action" value="ev_settings" />
      <?php 
    $ev_rss = $options['rss'];
    $ev_del = $options['delete'];
    ?>
      <p>
        <input type="checkbox" name="ev-rss" value="rss" <?php 
    if ($ev_rss == true) {
        echo "checked";
    }
    ?>
/>
        <?php 
    _e('Add video posts to Website RSS feed', 'external-videos');
    ?>
      </p>
      <p>
        <input type="checkbox" name="ev-delete" value="delete" <?php 
    if ($ev_del == true) {
        echo "checked";
    }
    ?>
/>
        <?php 
    _e('Move videos locally to trash when deleted on external site', 'external-videos');
    ?>
      </p>
      <p class="submit">
          <input type="submit" name="Submit" value="<?php 
    _e('Save');
    ?>
" />
      </p>
    </form>
    
    <h3><?php 
    _e('Update Videos (newly added/deleted videos)', 'external-videos');
    ?>
</h3>
    <form method="post" action="<?php 
    echo $_SERVER["REQUEST_URI"];
    ?>
">
        <input type="hidden" name="external_videos" value="Y" />
        <input type="hidden" name="action" value="sp_ev_update_videos" />
        <p class="submit">
            <input type="submit" name="Submit" value="<?php 
    _e('Update Videos from Channels', 'external-videos');
    ?>
" />
        </p>
    </form>
    <p><?php 
    _e('Next automatic update scheduled for:', 'external-videos');
    ?>
      <i><?php 
    echo date('Y-m-d H:i:s', wp_next_scheduled('ev_daily_event'));
    ?>
</i>
    </p><br/>

    <h3><?php 
    _e('Delete All Videos', 'external-videos');
    ?>
</h3>
    <p>
      <?php 
    _e('Be careful with this option - you will lose all links you have built between blog posts and the video pages. This is really only meant as a reset option.', 'external-videos');
    ?>
.
    </p>
    <form method="post" action="<?php 
    echo $_SERVER["REQUEST_URI"];
    ?>
">
        <input type="hidden" name="external_videos" value="Y" />
        <input type="hidden" name="action" value="sp_ev_delete_videos" />
        <p class="submit">
            <input type="submit" name="Submit" value="<?php 
    _e('Remove All Stored Videos From Channels', 'external-videos');
    ?>
" />
        </p>
    </form>

    </div>
    <?php 
}
 /**
  *  ajax_render_rules
  *
  *  @description creates the HTML for the field group rules metabox. Called from both Ajax and PHP
  *  @since 2.0
  *  I took this functions from the awesome Advanced custom fields plugin http://www.advancedcustomfields.com/
  */
 public static function ajax_render_rules($options = array())
 {
     // defaults
     $defaults = array('group_id' => 0, 'rule_id' => 0, 'value' => null, 'param' => null);
     $is_ajax = false;
     if (isset($_POST['nonce']) && wp_verify_nonce($_POST['nonce'], 'spu_nonce')) {
         $is_ajax = true;
     }
     // Is AJAX call?
     if ($is_ajax) {
         $options = array_merge($defaults, $_POST);
         $options['name'] = 'spu_rules[' . $options['group_id'] . '][' . $options['rule_id'] . '][value]';
     } else {
         $options = array_merge($defaults, $options);
     }
     // vars
     $choices = array();
     // some case's have the same outcome
     if ($options['param'] == "page_parent") {
         $options['param'] = "page";
     }
     switch ($options['param']) {
         case "post_type":
             // all post types except attachment
             $choices = apply_filters('spu/get_post_types', array(), array('attachment'));
             break;
         case "page":
             $post_type = 'page';
             $args = array('posts_per_page' => -1, 'post_type' => $post_type, 'orderby' => 'menu_order title', 'order' => 'ASC', 'post_status' => 'any', 'suppress_filters' => false, 'update_post_meta_cache' => false);
             $posts = get_posts(apply_filters('spu/rules/page_args', $args));
             if ($posts) {
                 // sort into hierachial order!
                 if (is_post_type_hierarchical($post_type)) {
                     $posts = get_page_children(0, $posts);
                 }
                 foreach ($posts as $page) {
                     $title = '';
                     $ancestors = get_ancestors($page->ID, 'page');
                     if ($ancestors) {
                         foreach ($ancestors as $a) {
                             $title .= '- ';
                         }
                     }
                     $title .= apply_filters('the_title', $page->post_title, $page->ID);
                     // status
                     if ($page->post_status != "publish") {
                         $title .= " ({$page->post_status})";
                     }
                     $choices[$page->ID] = $title;
                 }
                 // foreach($pages as $page)
             }
             break;
         case "page_type":
             $choices = array('all_pages' => __("All Pages", 'popups'), 'front_page' => __("Front Page", 'popups'), 'posts_page' => __("Posts Page", 'popups'), 'category_page' => __("Category Page", 'popups'), 'search_page' => __("Search Page", 'popups'), 'archive_page' => __("Archives Page", 'popups'), 'top_level' => __("Top Level Page (parent of 0)", 'popups'), 'parent' => __("Parent Page (has children)", 'popups'), 'child' => __("Child Page (has parent)", 'popups'));
             break;
         case "page_template":
             $choices = array('default' => __("Default Template", 'popups'));
             $templates = get_page_templates();
             foreach ($templates as $k => $v) {
                 $choices[$v] = $k;
             }
             break;
         case "post":
             $post_types = get_post_types();
             unset($post_types['page'], $post_types['attachment'], $post_types['revision'], $post_types['nav_menu_item'], $post_types['spucpt']);
             if ($post_types) {
                 foreach ($post_types as $post_type) {
                     $args = array('numberposts' => '-1', 'post_type' => $post_type, 'post_status' => array('publish', 'private', 'draft', 'inherit', 'future'), 'suppress_filters' => false);
                     $posts = get_posts(apply_filters('spu/rules/post_args', $args));
                     if ($posts) {
                         $choices[$post_type] = array();
                         foreach ($posts as $post) {
                             $title = apply_filters('the_title', $post->post_title, $post->ID);
                             // status
                             if ($post->post_status != "publish") {
                                 $title .= " ({$post->post_status})";
                             }
                             $choices[$post_type][$post->ID] = $title;
                         }
                         // foreach($posts as $post)
                     }
                     // if( $posts )
                 }
                 // foreach( $post_types as $post_type )
             }
             // if( $post_types )
             break;
         case "post_category":
             $categories = get_terms('category', array('get' => 'all', 'fields' => 'id=>name'));
             $choices = apply_filters('spu/rules/categories', $categories);
             break;
         case "post_format":
             $choices = get_post_format_strings();
             break;
         case "post_status":
             $choices = get_post_stati();
             break;
         case "user_type":
             global $wp_roles;
             $choices = $wp_roles->get_names();
             if (is_multisite()) {
                 $choices['super_admin'] = __('Super Admin');
             }
             break;
         case "taxonomy":
             $choices = array();
             $simple_value = true;
             $choices = apply_filters('spu/get_taxonomies', $choices, $simple_value);
             break;
         case "logged_user":
         case "mobiles":
         case "tablets":
         case "left_comment":
         case "search_engine":
         case "same_site":
             $choices = array('true' => __('True', 'popups'));
             break;
     }
     // allow custom rules rules
     $choices = apply_filters('spu/rules/rule_values/' . $options['param'], $choices);
     // Custom fields for rules
     do_action('spu/rules/print_' . $options['param'] . '_field', $options, $choices);
     // ajax?
     if ($is_ajax) {
         die;
     }
 }
 /**
  * Edit a post.
  *
  * @since 1.5.0
  *
  * @param array $args Method parameters.
  * @return bool True on success.
  */
 function mw_editPost($args)
 {
     $this->escape($args);
     $post_ID = (int) $args[0];
     $username = $args[1];
     $password = $args[2];
     $content_struct = $args[3];
     $publish = $args[4];
     if (!($user = $this->login($username, $password))) {
         return $this->error;
     }
     do_action('xmlrpc_call', 'metaWeblog.editPost');
     $cap = $publish ? 'publish_posts' : 'edit_posts';
     $error_message = __('Sorry, you are not allowed to publish posts on this site.');
     $post_type = 'post';
     $page_template = '';
     if (!empty($content_struct['post_type'])) {
         if ($content_struct['post_type'] == 'page') {
             if ($publish || 'publish' == $content_struct['page_status']) {
                 $cap = 'publish_pages';
             } else {
                 $cap = 'edit_pages';
             }
             $error_message = __('Sorry, you are not allowed to publish pages on this site.');
             $post_type = 'page';
             if (!empty($content_struct['wp_page_template'])) {
                 $page_template = $content_struct['wp_page_template'];
             }
         } elseif ($content_struct['post_type'] == 'post') {
             if ($publish || 'publish' == $content_struct['post_status']) {
                 $cap = 'publish_posts';
             } else {
                 $cap = 'edit_posts';
             }
             $error_message = __('Sorry, you are not allowed to publish posts on this site.');
             $post_type = 'post';
         } else {
             // No other post_type values are allowed here
             return new IXR_Error(401, __('Invalid post type.'));
         }
     } else {
         if ($publish || 'publish' == $content_struct['post_status']) {
             $cap = 'publish_posts';
         } else {
             $cap = 'edit_posts';
         }
         $error_message = __('Sorry, you are not allowed to publish posts on this site.');
         $post_type = 'post';
     }
     if (!current_user_can($cap)) {
         return new IXR_Error(401, $error_message);
     }
     // Check for a valid post format if one was given
     if (isset($content_struct['wp_post_format'])) {
         $content_struct['wp_post_format'] = sanitize_key($content_struct['wp_post_format']);
         if (!array_key_exists($content_struct['wp_post_format'], get_post_format_strings())) {
             return new IXR_Error(404, __('Invalid post format'));
         }
     }
     $postdata = wp_get_single_post($post_ID, ARRAY_A);
     // If there is no post data for the give post id, stop
     // now and return an error.  Other wise a new post will be
     // created (which was the old behavior).
     if (empty($postdata["ID"])) {
         return new IXR_Error(404, __('Invalid post ID.'));
     }
     $this->escape($postdata);
     extract($postdata, EXTR_SKIP);
     // Let WordPress manage slug if none was provided.
     $post_name = "";
     $post_name = $postdata['post_name'];
     if (isset($content_struct['wp_slug'])) {
         $post_name = $content_struct['wp_slug'];
     }
     // Only use a password if one was given.
     if (isset($content_struct['wp_password'])) {
         $post_password = $content_struct['wp_password'];
     }
     // Only set a post parent if one was given.
     if (isset($content_struct['wp_page_parent_id'])) {
         $post_parent = $content_struct['wp_page_parent_id'];
     }
     // Only set the menu_order if it was given.
     if (isset($content_struct['wp_page_order'])) {
         $menu_order = $content_struct['wp_page_order'];
     }
     $post_author = $postdata['post_author'];
     // Only set the post_author if one is set.
     if (isset($content_struct['wp_author_id']) && $user->ID != $content_struct['wp_author_id']) {
         switch ($post_type) {
             case 'post':
                 if (!current_user_can('edit_others_posts')) {
                     return new IXR_Error(401, __('You are not allowed to change the post author as this user.'));
                 }
                 break;
             case 'page':
                 if (!current_user_can('edit_others_pages')) {
                     return new IXR_Error(401, __('You are not allowed to change the page author as this user.'));
                 }
                 break;
             default:
                 return new IXR_Error(401, __('Invalid post type.'));
                 break;
         }
         $post_author = $content_struct['wp_author_id'];
     }
     if (isset($content_struct['mt_allow_comments'])) {
         if (!is_numeric($content_struct['mt_allow_comments'])) {
             switch ($content_struct['mt_allow_comments']) {
                 case 'closed':
                     $comment_status = 'closed';
                     break;
                 case 'open':
                     $comment_status = 'open';
                     break;
                 default:
                     $comment_status = get_option('default_comment_status');
                     break;
             }
         } else {
             switch ((int) $content_struct['mt_allow_comments']) {
                 case 0:
                 case 2:
                     $comment_status = 'closed';
                     break;
                 case 1:
                     $comment_status = 'open';
                     break;
                 default:
                     $comment_status = get_option('default_comment_status');
                     break;
             }
         }
     }
     if (isset($content_struct['mt_allow_pings'])) {
         if (!is_numeric($content_struct['mt_allow_pings'])) {
             switch ($content_struct['mt_allow_pings']) {
                 case 'closed':
                     $ping_status = 'closed';
                     break;
                 case 'open':
                     $ping_status = 'open';
                     break;
                 default:
                     $ping_status = get_option('default_ping_status');
                     break;
             }
         } else {
             switch ((int) $content_struct["mt_allow_pings"]) {
                 case 0:
                     $ping_status = 'closed';
                     break;
                 case 1:
                     $ping_status = 'open';
                     break;
                 default:
                     $ping_status = get_option('default_ping_status');
                     break;
             }
         }
     }
     $post_title = isset($content_struct['title']) ? $content_struct['title'] : null;
     $post_content = isset($content_struct['description']) ? $content_struct['description'] : null;
     $post_category = array();
     if (isset($content_struct['categories'])) {
         $catnames = $content_struct['categories'];
         if (is_array($catnames)) {
             foreach ($catnames as $cat) {
                 $post_category[] = get_cat_ID($cat);
             }
         }
     }
     $post_excerpt = isset($content_struct['mt_excerpt']) ? $content_struct['mt_excerpt'] : null;
     $post_more = isset($content_struct['mt_text_more']) ? $content_struct['mt_text_more'] : null;
     $post_status = $publish ? 'publish' : 'draft';
     if (isset($content_struct["{$post_type}_status"])) {
         switch ($content_struct["{$post_type}_status"]) {
             case 'draft':
             case 'pending':
             case 'private':
             case 'publish':
                 $post_status = $content_struct["{$post_type}_status"];
                 break;
             default:
                 $post_status = $publish ? 'publish' : 'draft';
                 break;
         }
     }
     $tags_input = isset($content_struct['mt_keywords']) ? $content_struct['mt_keywords'] : null;
     if ('publish' == $post_status) {
         if ('page' == $post_type && !current_user_can('publish_pages')) {
             return new IXR_Error(401, __('Sorry, you do not have the right to publish this page.'));
         } else {
             if (!current_user_can('publish_posts')) {
                 return new IXR_Error(401, __('Sorry, you do not have the right to publish this post.'));
             }
         }
     }
     if ($post_more) {
         $post_content = $post_content . "<!--more-->" . $post_more;
     }
     $to_ping = null;
     if (isset($content_struct['mt_tb_ping_urls'])) {
         $to_ping = $content_struct['mt_tb_ping_urls'];
         if (is_array($to_ping)) {
             $to_ping = implode(' ', $to_ping);
         }
     }
     // Do some timestamp voodoo
     if (!empty($content_struct['date_created_gmt'])) {
         $dateCreated = str_replace('Z', '', $content_struct['date_created_gmt']->getIso()) . 'Z';
     } elseif (!empty($content_struct['dateCreated'])) {
         $dateCreated = $content_struct['dateCreated']->getIso();
     }
     if (!empty($dateCreated)) {
         $post_date = get_date_from_gmt(iso8601_to_datetime($dateCreated));
         $post_date_gmt = iso8601_to_datetime($dateCreated, 'GMT');
     } else {
         $post_date = $postdata['post_date'];
         $post_date_gmt = $postdata['post_date_gmt'];
     }
     // We've got all the data -- post it:
     $newpost = compact('ID', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt', 'comment_status', 'ping_status', 'post_date', 'post_date_gmt', 'to_ping', 'post_name', 'post_password', 'post_parent', 'menu_order', 'post_author', 'tags_input', 'page_template');
     $result = wp_update_post($newpost, true);
     if (is_wp_error($result)) {
         return new IXR_Error(500, $result->get_error_message());
     }
     if (!$result) {
         return new IXR_Error(500, __('Sorry, your entry could not be edited. Something wrong happened.'));
     }
     // Only posts can be sticky
     if ($post_type == 'post' && isset($content_struct['sticky'])) {
         if ($content_struct['sticky'] == true) {
             stick_post($post_ID);
         } elseif ($content_struct['sticky'] == false) {
             unstick_post($post_ID);
         }
     }
     if (isset($content_struct['custom_fields'])) {
         $this->set_custom_fields($post_ID, $content_struct['custom_fields']);
     }
     // Handle enclosures
     $thisEnclosure = isset($content_struct['enclosure']) ? $content_struct['enclosure'] : null;
     $this->add_enclosure_if_new($post_ID, $thisEnclosure);
     $this->attach_uploads($ID, $post_content);
     // Handle post formats if assigned, validation is handled
     // earlier in this function
     if (isset($content_struct['wp_post_format'])) {
         wp_set_post_terms($post_ID, array('post-format-' . $content_struct['wp_post_format']), 'post_format');
     }
     logIO('O', "(MW) Edited ! ID: {$post_ID}");
     return true;
 }
Esempio n. 23
0
<label for="use_smilies">
<input name="use_smilies" type="checkbox" id="use_smilies" value="1" <?php checked('1', get_option('use_smilies')); ?> />
<?php _e('Convert emoticons like <code>:-)</code> and <code>:-P</code> to graphics on display') ?></label><br />
<label for="use_balanceTags"><input name="use_balanceTags" type="checkbox" id="use_balanceTags" value="1" <?php checked('1', get_option('use_balanceTags')); ?> /> <?php _e('WordPress should correct invalidly nested XHTML automatically') ?></label>
</fieldset></td>
</tr>
<tr>
<th scope="row"><label for="default_category"><?php _e('Default Post Category') ?></label></th>
<td>
<?php
wp_dropdown_categories(array('hide_empty' => 0, 'name' => 'default_category', 'orderby' => 'name', 'selected' => get_option('default_category'), 'hierarchical' => true));
?>
</td>
</tr>
<?php
$post_formats = get_post_format_strings();
unset( $post_formats['standard'] );
?>
<tr>
<th scope="row"><label for="default_post_format"><?php _e('Default Post Format') ?></label></th>
<td>
	<select name="default_post_format" id="default_post_format">
		<option value="0"><?php echo get_post_format_string( 'standard' ); ?></option>
<?php foreach ( $post_formats as $format_slug => $format_name ): ?>
		<option<?php selected( get_option( 'default_post_format' ), $format_slug ); ?> value="<?php echo esc_attr( $format_slug ); ?>"><?php echo esc_html( $format_name ); ?></option>
<?php endforeach; ?>
	</select>
</td>
</tr>
<?php
if ( get_option( 'link_manager_enabled' ) ) :
 /**
  * Collects the necessary information to return for a site's response.
  *
  * @return (array)
  */
 public function build_current_site_response()
 {
     global $wpdb, $wp_version;
     $response_format = self::$site_format;
     $is_user_logged_in = is_user_logged_in();
     $visible = array();
     if ($is_user_logged_in) {
         $current_user = wp_get_current_user();
         $visible = get_user_meta($current_user->ID, 'blog_visibility', true);
         if (!is_array($visible)) {
             $visible = array();
         }
     }
     $blog_id = (int) $this->api->get_blog_id_for_output();
     foreach (array_keys($response_format) as $key) {
         switch ($key) {
             case 'ID':
                 $response[$key] = $blog_id;
                 break;
             case 'name':
                 $response[$key] = (string) htmlspecialchars_decode(get_bloginfo('name'), ENT_QUOTES);
                 break;
             case 'description':
                 $response[$key] = (string) htmlspecialchars_decode(get_bloginfo('description'), ENT_QUOTES);
                 break;
             case 'URL':
                 $response[$key] = (string) home_url();
                 break;
             case 'jetpack':
                 $response[$key] = false;
                 // magic
                 break;
             case 'is_private':
                 if (defined('IS_WPCOM') && IS_WPCOM) {
                     $public_setting = get_option('blog_public');
                     if (-1 == $public_setting) {
                         $response[$key] = true;
                     } else {
                         $response[$key] = false;
                     }
                 } else {
                     $response[$key] = false;
                     // magic
                 }
                 break;
             case 'visible':
                 if ($is_user_logged_in) {
                     $is_visible = true;
                     if (isset($visible[$blog_id])) {
                         $is_visible = $visible[$blog_id];
                     }
                     // null and true are visible
                     $response[$key] = $is_visible;
                 }
                 break;
             case 'post_count':
                 if ($is_user_logged_in) {
                     $response[$key] = (int) $wpdb->get_var("SELECT COUNT(*) FROM {$wpdb->posts} WHERE post_status = 'publish'");
                 }
                 break;
             case 'lang':
                 if ($is_user_logged_in) {
                     $response[$key] = (string) get_bloginfo('language');
                 }
                 break;
             case 'icon':
                 if (function_exists('blavatar_domain') && function_exists('blavatar_exists') && function_exists('blavatar_url')) {
                     $domain = blavatar_domain(home_url());
                     if (blavatar_exists($domain)) {
                         $response[$key] = array('img' => (string) remove_query_arg('s', blavatar_url($domain, 'img')), 'ico' => (string) remove_query_arg('s', blavatar_url($domain, 'ico')));
                     }
                 }
                 break;
             case 'subscribers_count':
                 if (function_exists('wpcom_subs_total_wpcom_subscribers')) {
                     $total_wpcom_subs = wpcom_subs_total_wpcom_subscribers(array('blog_id' => $blog_id));
                     $response[$key] = $total_wpcom_subs;
                 } else {
                     $response[$key] = 0;
                     // magic
                 }
                 break;
             case 'is_following':
                 $response[$key] = (bool) $this->api->is_following($blog_id);
                 break;
             case 'options':
                 // Figure out if the blog supports VideoPress, have to do some extra checking for JP blogs
                 $has_videopress = false;
                 if (get_option('video_upgrade') == '1') {
                     $has_videopress = true;
                 } else {
                     if (class_exists('Jetpack_Options')) {
                         $videopress = Jetpack_Options::get_option('videopress', array());
                         if ($videopress['blog_id'] > 0) {
                             $has_videopress = true;
                         }
                     }
                 }
                 // Get a list of supported post formats
                 $all_formats = get_post_format_strings();
                 $supported = get_theme_support('post-formats');
                 $supported_formats = array();
                 if (isset($supported[0])) {
                     foreach ($supported[0] as $format) {
                         $supported_formats[$format] = $all_formats[$format];
                     }
                 }
                 // determine if sharing buttons should be visible by default
                 $default_sharing_status = false;
                 if (class_exists('Sharing_Service')) {
                     $ss = new Sharing_Service();
                     $blog_services = $ss->get_blog_services();
                     $default_sharing_status = !empty($blog_services['visible']);
                 }
                 $response[$key] = array('timezone' => (string) get_option('timezone_string'), 'gmt_offset' => (double) get_option('gmt_offset'), 'videopress_enabled' => $has_videopress, 'login_url' => wp_login_url(), 'admin_url' => get_admin_url(), 'featured_images_enabled' => current_theme_supports('post-thumbnails'), 'header_image' => get_theme_mod('header_image_data'), 'image_default_link_type' => get_option('image_default_link_type'), 'image_thumbnail_width' => (int) get_option('thumbnail_size_w'), 'image_thumbnail_height' => (int) get_option('thumbnail_size_h'), 'image_thumbnail_crop' => get_option('thumbnail_crop'), 'image_medium_width' => (int) get_option('medium_size_w'), 'image_medium_height' => (int) get_option('medium_size_h'), 'image_large_width' => (int) get_option('large_size_w'), 'image_large_height' => (int) get_option('large_size_h'), 'post_formats' => $supported_formats, 'default_likes_enabled' => (bool) apply_filters('wpl_is_enabled_sitewide', !get_option('disabled_likes')), 'default_sharing_status' => (bool) $default_sharing_status, 'default_comment_status' => 'closed' == get_option('default_comment_status') ? false : true, 'default_ping_status' => 'closed' == get_option('default_ping_status') ? false : true, 'software_version' => $wp_version);
                 if (!current_user_can('publish_posts')) {
                     unset($response[$key]);
                 }
                 break;
             case 'meta':
                 $xmlrpc_url = site_url('xmlrpc.php');
                 $response[$key] = (object) array('links' => (object) array('self' => (string) $this->get_site_link($blog_id), 'help' => (string) $this->get_site_link($blog_id, 'help'), 'posts' => (string) $this->get_site_link($blog_id, 'posts/'), 'comments' => (string) $this->get_site_link($blog_id, 'comments/'), 'xmlrpc' => (string) $xmlrpc_url));
                 break;
         }
     }
     return $response;
 }
Esempio n. 25
0
/*
 * Post endpoints
 */
new WPCOM_JSON_API_List_Posts_Endpoint(array('description' => 'Get a list of matching posts.', 'new_version' => '1.1', 'max_version' => '1', 'group' => 'posts', 'stat' => 'posts', 'method' => 'GET', 'path' => '/sites/%s/posts/', 'path_labels' => array('$site' => '(int|string) Site ID or domain'), 'query_parameters' => array('number' => '(int=20) The number of posts to return. Limit: 100.', 'offset' => '(int=0) 0-indexed offset.', 'page' => '(int) Return the Nth 1-indexed page of posts. Takes precedence over the <code>offset</code> parameter.', 'order' => array('DESC' => 'Return posts in descending order. For dates, that means newest to oldest.', 'ASC' => 'Return posts in ascending order. For dates, that means oldest to newest.'), 'order_by' => array('date' => 'Order by the created time of each post.', 'modified' => 'Order by the modified time of each post.', 'title' => "Order lexicographically by the posts' titles.", 'comment_count' => 'Order by the number of comments for each post.', 'ID' => 'Order by post ID.'), 'after' => '(ISO 8601 datetime) Return posts dated on or after the specified datetime.', 'before' => '(ISO 8601 datetime) Return posts dated on or before the specified datetime.', 'tag' => '(string) Specify the tag name or slug.', 'category' => '(string) Specify the category name or slug.', 'type' => "(string) Specify the post type. Defaults to 'post', use 'any' to query for both posts and pages. Post types besides post and page need to be whitelisted using the <code>rest_api_allowed_post_types</code> filter.", 'parent_id' => '(int) Returns only posts which are children of the specified post. Applies only to hierarchical post types.', 'exclude' => '(array:int|int) Excludes the specified post ID(s) from the response', 'exclude_tree' => '(int) Excludes the specified post and all of its descendants from the response. Applies only to hierarchical post types.', 'status' => array('publish' => 'Return only published posts.', 'private' => 'Return only private posts.', 'draft' => 'Return only draft posts.', 'pending' => 'Return only posts pending editorial approval.', 'future' => 'Return only posts scheduled for future publishing.', 'trash' => 'Return only posts in the trash.', 'any' => 'Return all posts regardless of status.'), 'sticky' => array('false' => 'Post is not marked as sticky.', 'true' => 'Stick the post to the front page.'), 'author' => "(int) Author's user ID", 'search' => '(string) Search query', 'meta_key' => '(string) Metadata key that the post should contain', 'meta_value' => '(string) Metadata value that the post should contain. Will only be applied if a `meta_key` is also given'), 'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/en.blog.wordpress.com/posts/?number=5'));
new WPCOM_JSON_API_List_Posts_v1_1_Endpoint(array('description' => 'Get a list of matching posts.', 'min_version' => '1.1', 'max_version' => '1.1', 'group' => 'posts', 'stat' => 'posts', 'method' => 'GET', 'path' => '/sites/%s/posts/', 'path_labels' => array('$site' => '(int|string) Site ID or domain'), 'query_parameters' => array('number' => '(int=20) The number of posts to return. Limit: 100.', 'offset' => '(int=0) 0-indexed offset.', 'page' => '(int) Return the Nth 1-indexed page of posts. Takes precedence over the <code>offset</code> parameter.', 'page_handle' => '(string) A page handle, returned from a previous API call as a <code>meta.next_page</code> property. This is the most efficient way to fetch the next page of results.', 'order' => array('DESC' => 'Return posts in descending order. For dates, that means newest to oldest.', 'ASC' => 'Return posts in ascending order. For dates, that means oldest to newest.'), 'order_by' => array('date' => 'Order by the created time of each post.', 'modified' => 'Order by the modified time of each post.', 'title' => "Order lexicographically by the posts' titles.", 'comment_count' => 'Order by the number of comments for each post.', 'ID' => 'Order by post ID.'), 'after' => '(ISO 8601 datetime) Return posts dated after the specified datetime.', 'before' => '(ISO 8601 datetime) Return posts dated before the specified datetime.', 'modified_after' => '(ISO 8601 datetime) Return posts modified after the specified datetime.', 'modified_before' => '(ISO 8601 datetime) Return posts modified before the specified datetime.', 'tag' => '(string) Specify the tag name or slug.', 'category' => '(string) Specify the category name or slug.', 'type' => "(string) Specify the post type. Defaults to 'post', use 'any' to query for both posts and pages. Post types besides post and page need to be whitelisted using the <code>rest_api_allowed_post_types</code> filter.", 'parent_id' => '(int) Returns only posts which are children of the specified post. Applies only to hierarchical post types.', 'exclude' => '(array:int|int) Excludes the specified post ID(s) from the response', 'exclude_tree' => '(int) Excludes the specified post and all of its descendants from the response. Applies only to hierarchical post types.', 'status' => '(string) Comma-separated list of statuses for which to query, including any of: "publish", "private", "draft", "pending", "future", and "trash", or simply "any". Defaults to "publish"', 'sticky' => array('include' => 'Sticky posts are not excluded from the list.', 'exclude' => 'Sticky posts are excluded from the list.', 'require' => 'Only include sticky posts'), 'author' => "(int) Author's user ID", 'search' => '(string) Search query', 'meta_key' => '(string) Metadata key that the post should contain', 'meta_value' => '(string) Metadata value that the post should contain. Will only be applied if a `meta_key` is also given'), 'example_request' => 'https://public-api.wordpress.com/rest/v1.1/sites/en.blog.wordpress.com/posts/?number=2'));
new WPCOM_JSON_API_Get_Post_Endpoint(array('description' => 'Get a single post (by ID).', 'group' => 'posts', 'stat' => 'posts:1', 'new_version' => '1.1', 'max_version' => '1', 'method' => 'GET', 'path' => '/sites/%s/posts/%d', 'path_labels' => array('$site' => '(int|string) Site ID or domain', '$post_ID' => '(int) The post ID'), 'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/en.blog.wordpress.com/posts/7'));
new WPCOM_JSON_API_Get_Post_v1_1_Endpoint(array('description' => 'Get a single post (by ID).', 'min_version' => '1.1', 'max_version' => '1.1', 'group' => 'posts', 'stat' => 'posts:1', 'method' => 'GET', 'path' => '/sites/%s/posts/%d', 'path_labels' => array('$site' => '(int|string) Site ID or domain', '$post_ID' => '(int) The post ID'), 'example_request' => 'https://public-api.wordpress.com/rest/v1.1/sites/en.blog.wordpress.com/posts/7'));
new WPCOM_JSON_API_Get_Post_Endpoint(array('description' => 'Get a single post (by name)', 'group' => '__do_not_document', 'stat' => 'posts:name', 'method' => 'GET', 'path' => '/sites/%s/posts/name:%s', 'path_labels' => array('$site' => '(int|string) Site ID or domain', '$post_name' => '(string) The post name (a.k.a. slug)'), 'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/en.blog.wordpress.com/posts/name:blogging-and-stuff?pretty=1'));
new WPCOM_JSON_API_Get_Post_Endpoint(array('description' => 'Get a single post (by slug).', 'group' => 'posts', 'stat' => 'posts:slug', 'new_version' => '1.1', 'max_version' => '1', 'method' => 'GET', 'path' => '/sites/%s/posts/slug:%s', 'path_labels' => array('$site' => '(int|string) Site ID or domain', '$post_slug' => '(string) The post slug (a.k.a. sanitized name)'), 'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/en.blog.wordpress.com/posts/slug:blogging-and-stuff'));
new WPCOM_JSON_API_Get_Post_v1_1_Endpoint(array('description' => 'Get a single post (by slug).', 'min_version' => '1.1', 'max_version' => '1.1', 'group' => 'posts', 'stat' => 'posts:slug', 'method' => 'GET', 'path' => '/sites/%s/posts/slug:%s', 'path_labels' => array('$site' => '(int|string) Site ID or domain', '$post_slug' => '(string) The post slug (a.k.a. sanitized name)'), 'example_request' => 'https://public-api.wordpress.com/rest/v1.1/sites/en.blog.wordpress.com/posts/slug:blogging-and-stuff'));
new WPCOM_JSON_API_Update_Post_Endpoint(array('description' => 'Create a post.', 'group' => 'posts', 'stat' => 'posts:new', 'new_version' => '1.2', 'max_version' => '1', 'method' => 'POST', 'path' => '/sites/%s/posts/new', 'path_labels' => array('$site' => '(int|string) Site ID or domain'), 'request_format' => array('date' => "(ISO 8601 datetime) The post's creation time.", 'title' => '(HTML) The post title.', 'content' => '(HTML) The post content.', 'excerpt' => '(HTML) An optional post excerpt.', 'slug' => '(string) The name (slug) for the post, used in URLs.', 'author' => '(string) The username or ID for the user to assign the post to.', 'publicize' => '(array|bool) True or false if the post be publicized to external services. An array of services if we only want to publicize to a select few. Defaults to true.', 'publicize_message' => '(string) Custom message to be publicized to external services.', 'status' => array('publish' => 'Publish the post.', 'private' => 'Privately publish the post.', 'draft' => 'Save the post as a draft.', 'pending' => 'Mark the post as pending editorial approval.', 'auto-draft' => 'Save a placeholder for a newly created post, with no content.'), 'sticky' => array('false' => 'Post is not marked as sticky.', 'true' => 'Stick the post to the front page.'), 'password' => '(string) The plaintext password protecting the post, or, more likely, the empty string if the post is not password protected.', 'parent' => "(int) The post ID of the new post's parent.", 'type' => "(string) The post type. Defaults to 'post'. Post types besides post and page need to be whitelisted using the <code>rest_api_allowed_post_types</code> filter.", 'categories' => "(array|string) Comma-separated list or array of categories (name or id)", 'tags' => "(array|string) Comma-separated list or array of tags (name or id)", 'format' => array_merge(array('default' => 'Use default post format'), get_post_format_strings()), 'featured_image' => "(string) The post ID of an existing attachment to set as the featured image. Pass an empty string to delete the existing image.", 'media' => "(media) An array of files to attach to the post. To upload media, the entire request should be multipart/form-data encoded. Multiple media items will be displayed in a gallery. Accepts  jpg, jpeg, png, gif, pdf, doc, ppt, odt, pptx, docx, pps, ppsx, xls, xlsx, key. Audio and Video may also be available. See <code>allowed_file_types</code> in the options response of the site endpoint. <br /><br /><strong>Example</strong>:<br />" . "<code>curl \\<br />--form 'title=Image' \\<br />--form 'media[]=@/path/to/file.jpg' \\<br />-H 'Authorization: BEARER your-token' \\<br />'https://public-api.wordpress.com/rest/v1/sites/123/posts/new'</code>", 'media_urls' => "(array) An array of URLs for images to attach to a post. Sideloads the media in for a post.", 'metadata' => "(array) Array of metadata objects containing the following properties: `key` (metadata key), `id` (meta ID), `previous_value` (if set, the action will only occur for the provided previous value), `value` (the new value to set the meta to), `operation` (the operation to perform: `update` or `add`; defaults to `update`). All unprotected meta keys are available by default for read requests. Both unprotected and protected meta keys are avaiable for authenticated requests with proper capabilities. Protected meta keys can be made available with the <code>rest_api_allowed_public_metadata</code> filter.", 'comments_open' => "(bool) Should the post be open to comments? Defaults to the blog's preference.", 'pings_open' => "(bool) Should the post be open to comments? Defaults to the blog's preference.", 'likes_enabled' => "(bool) Should the post be open to likes? Defaults to the blog's preference.", 'sharing_enabled' => "(bool) Should sharing buttons show on this post? Defaults to true.", 'menu_order' => "(int) (Pages Only) the order pages should appear in. Use 0 to maintain alphabetical order."), 'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/82974409/posts/new/', 'example_request_data' => array('headers' => array('authorization' => 'Bearer YOUR_API_TOKEN'), 'body' => array('title' => 'Hello World', 'content' => 'Hello. I am a test post. I was created by the API', 'tags' => 'tests', 'categories' => 'API'))));
new WPCOM_JSON_API_Update_Post_v1_1_Endpoint(array('description' => 'Create a post.', 'group' => 'posts', 'stat' => 'posts:new', 'new_version' => '1.2', 'min_version' => '1.1', 'max_version' => '1.1', 'method' => 'POST', 'path' => '/sites/%s/posts/new', 'path_labels' => array('$site' => '(int|string) Site ID or domain'), 'request_format' => array('date' => "(ISO 8601 datetime) The post's creation time.", 'title' => '(HTML) The post title.', 'content' => '(HTML) The post content.', 'excerpt' => '(HTML) An optional post excerpt.', 'slug' => '(string) The name (slug) for the post, used in URLs.', 'author' => '(string) The username or ID for the user to assign the post to.', 'publicize' => '(array|bool) True or false if the post be publicized to external services. An array of services if we only want to publicize to a select few. Defaults to true.', 'publicize_message' => '(string) Custom message to be publicized to external services.', 'status' => array('publish' => 'Publish the post.', 'private' => 'Privately publish the post.', 'draft' => 'Save the post as a draft.', 'pending' => 'Mark the post as pending editorial approval.', 'future' => 'Schedule the post (alias for publish; you must also set a future date).', 'auto-draft' => 'Save a placeholder for a newly created post, with no content.'), 'sticky' => array('false' => 'Post is not marked as sticky.', 'true' => 'Stick the post to the front page.'), 'password' => '(string) The plaintext password protecting the post, or, more likely, the empty string if the post is not password protected.', 'parent' => "(int) The post ID of the new post's parent.", 'type' => "(string) The post type. Defaults to 'post'. Post types besides post and page need to be whitelisted using the <code>rest_api_allowed_post_types</code> filter.", 'terms' => '(object) Mapping of taxonomy to comma-separated list or array of terms (name or id)', 'categories' => "(array|string) Comma-separated list or array of categories (name or id)", 'tags' => "(array|string) Comma-separated list or array of tags (name or id)", 'format' => array_merge(array('default' => 'Use default post format'), get_post_format_strings()), 'featured_image' => "(string) The post ID of an existing attachment to set as the featured image. Pass an empty string to delete the existing image.", 'media' => "(media) An array of files to attach to the post. To upload media, the entire request should be multipart/form-data encoded. Multiple media items will be displayed in a gallery. Accepts  jpg, jpeg, png, gif, pdf, doc, ppt, odt, pptx, docx, pps, ppsx, xls, xlsx, key. Audio and Video may also be available. See <code>allowed_file_types</code> in the options response of the site endpoint. Errors produced by media uploads, if any, will be in `media_errors` in the response. <br /><br /><strong>Example</strong>:<br />" . "<code>curl \\<br />--form 'title=Image Post' \\<br />--form 'media[0]=@/path/to/file.jpg' \\<br />--form 'media_attrs[0][caption]=My Great Photo' \\<br />-H 'Authorization: BEARER your-token' \\<br />'https://public-api.wordpress.com/rest/v1/sites/123/posts/new'</code>", 'media_urls' => "(array) An array of URLs for images to attach to a post. Sideloads the media in for a post. Errors produced by media sideloading, if any, will be in `media_errors` in the response.", 'media_attrs' => "(array) An array of attributes (`title`, `description` and `caption`) are supported to assign to the media uploaded via the `media` or `media_urls` properties. You must use a numeric index for the keys of `media_attrs` which follow the same sequence as `media` and `media_urls`. <br /><br /><strong>Example</strong>:<br />" . "<code>curl \\<br />--form 'title=Gallery Post' \\<br />--form 'media[]=@/path/to/file1.jpg' \\<br />--form 'media_urls[]=http://exapmple.com/file2.jpg' \\<br /> \\<br />--form 'media_attrs[0][caption]=This will be the caption for file1.jpg' \\<br />--form 'media_attrs[1][title]=This will be the title for file2.jpg' \\<br />-H 'Authorization: BEARER your-token' \\<br />'https://public-api.wordpress.com/rest/v1/sites/123/posts/new'</code>", 'metadata' => "(array) Array of metadata objects containing the following properties: `key` (metadata key), `id` (meta ID), `previous_value` (if set, the action will only occur for the provided previous value), `value` (the new value to set the meta to), `operation` (the operation to perform: `update` or `add`; defaults to `update`). All unprotected meta keys are available by default for read requests. Both unprotected and protected meta keys are avaiable for authenticated requests with proper capabilities. Protected meta keys can be made available with the <code>rest_api_allowed_public_metadata</code> filter.", 'discussion' => '(object) A hash containing one or more of the following boolean values, which default to the blog\'s discussion preferences: `comments_open`, `pings_open`', 'likes_enabled' => "(bool) Should the post be open to likes? Defaults to the blog's preference.", 'sharing_enabled' => "(bool) Should sharing buttons show on this post? Defaults to true.", 'menu_order' => "(int) (Pages Only) the order pages should appear in. Use 0 to maintain alphabetical order.", 'page_template' => '(string) (Pages Only) The page template this page should use.'), 'example_request' => 'https://public-api.wordpress.com/rest/v1.1/sites/82974409/posts/new/', 'example_request_data' => array('headers' => array('authorization' => 'Bearer YOUR_API_TOKEN'), 'body' => array('title' => 'Hello World', 'content' => 'Hello. I am a test post. I was created by the API', 'tags' => 'tests', 'categories' => 'API'))));
new WPCOM_JSON_API_Update_Post_v1_2_Endpoint(array('description' => 'Create a post.', 'group' => 'posts', 'stat' => 'posts:new', 'min_version' => '1.2', 'max_version' => '1.2', 'method' => 'POST', 'path' => '/sites/%s/posts/new', 'path_labels' => array('$site' => '(int|string) Site ID or domain'), 'request_format' => array('date' => "(ISO 8601 datetime) The post's creation time.", 'title' => '(HTML) The post title.', 'content' => '(HTML) The post content.', 'excerpt' => '(HTML) An optional post excerpt.', 'slug' => '(string) The name (slug) for the post, used in URLs.', 'author' => '(string) The username or ID for the user to assign the post to.', 'publicize' => '(array|bool) True or false if the post be publicized to external services. An array of services if we only want to publicize to a select few. Defaults to true.', 'publicize_message' => '(string) Custom message to be publicized to external services.', 'status' => array('publish' => 'Publish the post.', 'private' => 'Privately publish the post.', 'draft' => 'Save the post as a draft.', 'pending' => 'Mark the post as pending editorial approval.', 'future' => 'Schedule the post (alias for publish; you must also set a future date).', 'auto-draft' => 'Save a placeholder for a newly created post, with no content.'), 'sticky' => array('false' => 'Post is not marked as sticky.', 'true' => 'Stick the post to the front page.'), 'password' => '(string) The plaintext password protecting the post, or, more likely, the empty string if the post is not password protected.', 'parent' => "(int) The post ID of the new post's parent.", 'type' => "(string) The post type. Defaults to 'post'. Post types besides post and page need to be whitelisted using the <code>rest_api_allowed_post_types</code> filter.", 'terms' => '(object) Mapping of taxonomy to comma-separated list or array of term names', 'categories' => "(array|string) Comma-separated list or array of category names", 'tags' => "(array|string) Comma-separated list or array of tag names", 'terms_by_id' => '(object) Mapping of taxonomy to comma-separated list or array of term IDs', 'categories_by_id' => "(array|string) Comma-separated list or array of category IDs", 'tags_by_id' => "(array|string) Comma-separated list or array of tag IDs", 'format' => array_merge(array('default' => 'Use default post format'), get_post_format_strings()), 'featured_image' => "(string) The post ID of an existing attachment to set as the featured image. Pass an empty string to delete the existing image.", 'media' => "(media) An array of files to attach to the post. To upload media, the entire request should be multipart/form-data encoded. Multiple media items will be displayed in a gallery. Accepts  jpg, jpeg, png, gif, pdf, doc, ppt, odt, pptx, docx, pps, ppsx, xls, xlsx, key. Audio and Video may also be available. See <code>allowed_file_types</code> in the options response of the site endpoint. Errors produced by media uploads, if any, will be in `media_errors` in the response. <br /><br /><strong>Example</strong>:<br />" . "<code>curl \\<br />--form 'title=Image Post' \\<br />--form 'media[0]=@/path/to/file.jpg' \\<br />--form 'media_attrs[0][caption]=My Great Photo' \\<br />-H 'Authorization: BEARER your-token' \\<br />'https://public-api.wordpress.com/rest/v1/sites/123/posts/new'</code>", 'media_urls' => "(array) An array of URLs for images to attach to a post. Sideloads the media in for a post. Errors produced by media sideloading, if any, will be in `media_errors` in the response.", 'media_attrs' => "(array) An array of attributes (`title`, `description` and `caption`) are supported to assign to the media uploaded via the `media` or `media_urls` properties. You must use a numeric index for the keys of `media_attrs` which follow the same sequence as `media` and `media_urls`. <br /><br /><strong>Example</strong>:<br />" . "<code>curl \\<br />--form 'title=Gallery Post' \\<br />--form 'media[]=@/path/to/file1.jpg' \\<br />--form 'media_urls[]=http://exapmple.com/file2.jpg' \\<br /> \\<br />--form 'media_attrs[0][caption]=This will be the caption for file1.jpg' \\<br />--form 'media_attrs[1][title]=This will be the title for file2.jpg' \\<br />-H 'Authorization: BEARER your-token' \\<br />'https://public-api.wordpress.com/rest/v1/sites/123/posts/new'</code>", 'metadata' => "(array) Array of metadata objects containing the following properties: `key` (metadata key), `id` (meta ID), `previous_value` (if set, the action will only occur for the provided previous value), `value` (the new value to set the meta to), `operation` (the operation to perform: `update` or `add`; defaults to `update`). All unprotected meta keys are available by default for read requests. Both unprotected and protected meta keys are avaiable for authenticated requests with proper capabilities. Protected meta keys can be made available with the <code>rest_api_allowed_public_metadata</code> filter.", 'discussion' => '(object) A hash containing one or more of the following boolean values, which default to the blog\'s discussion preferences: `comments_open`, `pings_open`', 'likes_enabled' => "(bool) Should the post be open to likes? Defaults to the blog's preference.", 'sharing_enabled' => "(bool) Should sharing buttons show on this post? Defaults to true.", 'menu_order' => "(int) (Pages Only) the order pages should appear in. Use 0 to maintain alphabetical order.", 'page_template' => '(string) (Pages Only) The page template this page should use.'), 'example_request' => 'https://public-api.wordpress.com/rest/v1.2/sites/82974409/posts/new/', 'example_request_data' => array('headers' => array('authorization' => 'Bearer YOUR_API_TOKEN'), 'body' => array('title' => 'Hello World', 'content' => 'Hello. I am a test post. I was created by the API', 'tags' => 'tests', 'categories' => 'API'))));
new WPCOM_JSON_API_Update_Post_Endpoint(array('description' => 'Edit a post.', 'group' => 'posts', 'stat' => 'posts:1:POST', 'new_version' => '1.2', 'max_version' => '1', 'method' => 'POST', 'path' => '/sites/%s/posts/%d', 'path_labels' => array('$site' => '(int|string) Site ID or domain', '$post_ID' => '(int) The post ID'), 'request_format' => array('date' => "(ISO 8601 datetime) The post's creation time.", 'title' => '(HTML) The post title.', 'content' => '(HTML) The post content.', 'excerpt' => '(HTML) An optional post excerpt.', 'slug' => '(string) The name (slug) for the post, used in URLs.', 'author' => '(string) The username or ID for the user to assign the post to.', 'publicize' => '(array|bool) True or false if the post be publicized to external services. An array of services if we only want to publicize to a select few. Defaults to true.', 'publicize_message' => '(string) Custom message to be publicized to external services.', 'status' => array('publish' => 'Publish the post.', 'private' => 'Privately publish the post.', 'draft' => 'Save the post as a draft.', 'pending' => 'Mark the post as pending editorial approval.', 'trash' => 'Set the post as trashed.'), 'sticky' => array('false' => 'Post is not marked as sticky.', 'true' => 'Stick the post to the front page.'), 'password' => '(string) The plaintext password protecting the post, or, more likely, the empty string if the post is not password protected.', 'parent' => "(int) The post ID of the new post's parent.", 'categories' => "(array|string) Comma-separated list or array of categories (name or id)", 'tags' => "(array|string) Comma-separated list or array of tags (name or id)", 'format' => array_merge(array('default' => 'Use default post format'), get_post_format_strings()), 'comments_open' => '(bool) Should the post be open to comments?', 'pings_open' => '(bool) Should the post be open to comments?', 'likes_enabled' => "(bool) Should the post be open to likes?", 'menu_order' => "(int) (Pages Only) the order pages should appear in. Use 0 to maintain alphabetical order.", 'sharing_enabled' => "(bool) Should sharing buttons show on this post?", 'featured_image' => "(string) The post ID of an existing attachment to set as the featured image. Pass an empty string to delete the existing image.", 'media' => "(media) An array of files to attach to the post. To upload media, the entire request should be multipart/form-data encoded. Multiple media items will be displayed in a gallery. Accepts  jpg, jpeg, png, gif, pdf, doc, ppt, odt, pptx, docx, pps, ppsx, xls, xlsx, key. Audio and Video may also be available. See <code>allowed_file_types</code> in the options resposne of the site endpoint. <br /><br /><strong>Example</strong>:<br />" . "<code>curl \\<br />--form 'title=Image' \\<br />--form 'media[]=@/path/to/file.jpg' \\<br />-H 'Authorization: BEARER your-token' \\<br />'https://public-api.wordpress.com/rest/v1/sites/123/posts/new'</code>", 'media_urls' => "(array) An array of URLs for images to attach to a post. Sideloads the media in for a post.", 'metadata' => "(array) Array of metadata objects containing the following properties: `key` (metadata key), `id` (meta ID), `previous_value` (if set, the action will only occur for the provided previous value), `value` (the new value to set the meta to), `operation` (the operation to perform: `update` or `add`; defaults to `update`). All unprotected meta keys are available by default for read requests. Both unprotected and protected meta keys are available for authenticated requests with proper capabilities. Protected meta keys can be made available with the <code>rest_api_allowed_public_metadata</code> filter."), 'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/82974409/posts/881', 'example_request_data' => array('headers' => array('authorization' => 'Bearer YOUR_API_TOKEN'), 'body' => array('title' => 'Hello World (Again)', 'content' => 'Hello. I am an edited post. I was edited by the API', 'tags' => 'tests', 'categories' => 'API'))));
new WPCOM_JSON_API_Update_Post_v1_1_Endpoint(array('description' => 'Edit a post.', 'group' => 'posts', 'stat' => 'posts:1:POST', 'new_version' => '1.2', 'min_version' => '1.1', 'max_version' => '1.1', 'method' => 'POST', 'path' => '/sites/%s/posts/%d', 'path_labels' => array('$site' => '(int|string) Site ID or domain', '$post_ID' => '(int) The post ID'), 'request_format' => array('date' => "(ISO 8601 datetime) The post's creation time.", 'title' => '(HTML) The post title.', 'content' => '(HTML) The post content.', 'excerpt' => '(HTML) An optional post excerpt.', 'slug' => '(string) The name (slug) for the post, used in URLs.', 'author' => '(string) The username or ID for the user to assign the post to.', 'publicize' => '(array|bool) True or false if the post be publicized to external services. An array of services if we only want to publicize to a select few. Defaults to true.', 'publicize_message' => '(string) Custom message to be publicized to external services.', 'status' => array('publish' => 'Publish the post.', 'private' => 'Privately publish the post.', 'draft' => 'Save the post as a draft.', 'future' => 'Schedule the post (alias for publish; you must also set a future date).', 'pending' => 'Mark the post as pending editorial approval.', 'trash' => 'Set the post as trashed.'), 'sticky' => array('false' => 'Post is not marked as sticky.', 'true' => 'Stick the post to the front page.'), 'password' => '(string) The plaintext password protecting the post, or, more likely, the empty string if the post is not password protected.', 'parent' => "(int) The post ID of the new post's parent.", 'terms' => '(object) Mapping of taxonomy to comma-separated list or array of terms (name or id)', 'categories' => "(array|string) Comma-separated list or array of categories (name or id)", 'tags' => "(array|string) Comma-separated list or array of tags (name or id)", 'format' => array_merge(array('default' => 'Use default post format'), get_post_format_strings()), 'discussion' => '(object) A hash containing one or more of the following boolean values, which default to the blog\'s discussion preferences: `comments_open`, `pings_open`', 'likes_enabled' => "(bool) Should the post be open to likes?", 'menu_order' => "(int) (Pages only) the order pages should appear in. Use 0 to maintain alphabetical order.", 'page_template' => '(string) (Pages Only) The page template this page should use.', 'sharing_enabled' => "(bool) Should sharing buttons show on this post?", 'featured_image' => "(string) The post ID of an existing attachment to set as the featured image. Pass an empty string to delete the existing image.", 'media' => "(media) An array of files to attach to the post. To upload media, the entire request should be multipart/form-data encoded. Multiple media items will be displayed in a gallery. Accepts  jpg, jpeg, png, gif, pdf, doc, ppt, odt, pptx, docx, pps, ppsx, xls, xlsx, key. Audio and Video may also be available. See <code>allowed_file_types</code> in the options resposne of the site endpoint. <br /><br /><strong>Example</strong>:<br />" . "<code>curl \\<br />--form 'title=Image' \\<br />--form 'media[]=@/path/to/file.jpg' \\<br />-H 'Authorization: BEARER your-token' \\<br />'https://public-api.wordpress.com/rest/v1/sites/123/posts/new'</code>", 'media_urls' => "(array) An array of URLs for images to attach to a post. Sideloads the media in for a post.", 'metadata' => "(array) Array of metadata objects containing the following properties: `key` (metadata key), `id` (meta ID), `previous_value` (if set, the action will only occur for the provided previous value), `value` (the new value to set the meta to), `operation` (the operation to perform: `update` or `add`; defaults to `update`). All unprotected meta keys are available by default for read requests. Both unprotected and protected meta keys are available for authenticated requests with proper capabilities. Protected meta keys can be made available with the <code>rest_api_allowed_public_metadata</code> filter."), 'example_request' => 'https://public-api.wordpress.com/rest/v1.1/sites/82974409/posts/881', 'example_request_data' => array('headers' => array('authorization' => 'Bearer YOUR_API_TOKEN'), 'body' => array('title' => 'Hello World (Again)', 'content' => 'Hello. I am an edited post. I was edited by the API', 'tags' => 'tests', 'categories' => 'API'))));
new WPCOM_JSON_API_Update_Post_v1_2_Endpoint(array('description' => 'Edit a post.', 'group' => 'posts', 'stat' => 'posts:1:POST', 'min_version' => '1.2', 'max_version' => '1.2', 'method' => 'POST', 'path' => '/sites/%s/posts/%d', 'path_labels' => array('$site' => '(int|string) Site ID or domain', '$post_ID' => '(int) The post ID'), 'request_format' => array('date' => "(ISO 8601 datetime) The post's creation time.", 'title' => '(HTML) The post title.', 'content' => '(HTML) The post content.', 'excerpt' => '(HTML) An optional post excerpt.', 'slug' => '(string) The name (slug) for the post, used in URLs.', 'author' => '(string) The username or ID for the user to assign the post to.', 'publicize' => '(array|bool) True or false if the post be publicized to external services. An array of services if we only want to publicize to a select few. Defaults to true.', 'publicize_message' => '(string) Custom message to be publicized to external services.', 'status' => array('publish' => 'Publish the post.', 'private' => 'Privately publish the post.', 'draft' => 'Save the post as a draft.', 'future' => 'Schedule the post (alias for publish; you must also set a future date).', 'pending' => 'Mark the post as pending editorial approval.', 'trash' => 'Set the post as trashed.'), 'sticky' => array('false' => 'Post is not marked as sticky.', 'true' => 'Stick the post to the front page.'), 'password' => '(string) The plaintext password protecting the post, or, more likely, the empty string if the post is not password protected.', 'parent' => "(int) The post ID of the new post's parent.", 'terms' => '(object) Mapping of taxonomy to comma-separated list or array of term names', 'terms_by_id' => '(object) Mapping of taxonomy to comma-separated list or array of term IDs', 'categories' => "(array|string) Comma-separated list or array of category names", 'categories_by_id' => "(array|string) Comma-separated list or array of category IDs", 'tags' => "(array|string) Comma-separated list or array of tag names", 'tags_by_id' => "(array|string) Comma-separated list or array of tag IDs", 'format' => array_merge(array('default' => 'Use default post format'), get_post_format_strings()), 'discussion' => '(object) A hash containing one or more of the following boolean values, which default to the blog\'s discussion preferences: `comments_open`, `pings_open`', 'likes_enabled' => "(bool) Should the post be open to likes?", 'menu_order' => "(int) (Pages only) the order pages should appear in. Use 0 to maintain alphabetical order.", 'page_template' => '(string) (Pages Only) The page template this page should use.', 'sharing_enabled' => "(bool) Should sharing buttons show on this post?", 'featured_image' => "(string) The post ID of an existing attachment to set as the featured image. Pass an empty string to delete the existing image.", 'media' => "(media) An array of files to attach to the post. To upload media, the entire request should be multipart/form-data encoded. Multiple media items will be displayed in a gallery. Accepts  jpg, jpeg, png, gif, pdf, doc, ppt, odt, pptx, docx, pps, ppsx, xls, xlsx, key. Audio and Video may also be available. See <code>allowed_file_types</code> in the options resposne of the site endpoint. <br /><br /><strong>Example</strong>:<br />" . "<code>curl \\<br />--form 'title=Image' \\<br />--form 'media[]=@/path/to/file.jpg' \\<br />-H 'Authorization: BEARER your-token' \\<br />'https://public-api.wordpress.com/rest/v1/sites/123/posts/new'</code>", 'media_urls' => "(array) An array of URLs for images to attach to a post. Sideloads the media in for a post.", 'metadata' => "(array) Array of metadata objects containing the following properties: `key` (metadata key), `id` (meta ID), `previous_value` (if set, the action will only occur for the provided previous value), `value` (the new value to set the meta to), `operation` (the operation to perform: `update` or `add`; defaults to `update`). All unprotected meta keys are available by default for read requests. Both unprotected and protected meta keys are available for authenticated requests with proper capabilities. Protected meta keys can be made available with the <code>rest_api_allowed_public_metadata</code> filter."), 'example_request' => 'https://public-api.wordpress.com/rest/v1.2/sites/82974409/posts/881', 'example_request_data' => array('headers' => array('authorization' => 'Bearer YOUR_API_TOKEN'), 'body' => array('title' => 'Hello World (Again)', 'content' => 'Hello. I am an edited post. I was edited by the API', 'tags' => 'tests', 'categories' => 'API'))));
new WPCOM_JSON_API_Update_Post_Endpoint(array('description' => 'Delete a post. Note: If the post object is of type post or page and the trash is enabled, this request will send the post to the trash. A second request will permanently delete the post.', 'group' => 'posts', 'stat' => 'posts:1:delete', 'new_version' => '1.1', 'max_version' => '1', 'method' => 'POST', 'path' => '/sites/%s/posts/%d/delete', 'path_labels' => array('$site' => '(int|string) Site ID or domain', '$post_ID' => '(int) The post ID'), 'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/82974409/posts/$post_ID/delete/', 'example_request_data' => array('headers' => array('authorization' => 'Bearer YOUR_API_TOKEN'))));
new WPCOM_JSON_API_Update_Post_v1_1_Endpoint(array('description' => 'Delete a post. Note: If the post object is of type post or page and the trash is enabled, this request will send the post to the trash. A second request will permanently delete the post.', 'group' => 'posts', 'stat' => 'posts:1:delete', 'min_version' => '1.1', 'max_version' => '1.1', 'method' => 'POST', 'path' => '/sites/%s/posts/%d/delete', 'path_labels' => array('$site' => '(int|string) Site ID or domain', '$post_ID' => '(int) The post ID'), 'example_request' => 'https://public-api.wordpress.com/rest/v1.1/sites/82974409/posts/$post_ID/delete/', 'example_request_data' => array('headers' => array('authorization' => 'Bearer YOUR_API_TOKEN'))));
new WPCOM_JSON_API_Update_Post_Endpoint(array('description' => 'Restore a post or page from the trash to its previous status.', 'group' => 'posts', 'stat' => 'posts:1:restore', 'method' => 'POST', 'new_version' => '1.1', 'max_version' => '1', 'path' => '/sites/%s/posts/%d/restore', 'path_labels' => array('$site' => '(int|string) Site ID or domain', '$post_ID' => '(int) The post ID'), 'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/82974409/posts/$post_ID/restore/', 'example_request_data' => array('headers' => array('authorization' => 'Bearer YOUR_API_TOKEN'))));
new WPCOM_JSON_API_Update_Post_v1_1_Endpoint(array('description' => 'Restore a post or page from the trash to its previous status.', 'group' => 'posts', 'stat' => 'posts:1:restore', 'min_version' => '1.1', 'max_version' => '1.1', 'method' => 'POST', 'path' => '/sites/%s/posts/%d/restore', 'path_labels' => array('$site' => '(int|string) Site ID or domain', '$post_ID' => '(int) The post ID'), 'example_request' => 'https://public-api.wordpress.com/rest/v1.1/sites/82974409/posts/$post_ID/restore/', 'example_request_data' => array('headers' => array('authorization' => 'Bearer YOUR_API_TOKEN'))));
new WPCOM_JSON_API_Get_Autosave_v1_1_Endpoint(array('description' => 'Get the most recent autosave for a post.', 'group' => '__do_not_document', 'stat' => 'posts:autosave', 'min_version' => '1.1', 'method' => 'GET', 'path' => '/sites/%s/posts/%d/autosave', 'path_labels' => array('$site' => '(int|string) Site ID or domain', '$post_ID' => '(int) The post ID'), 'response_format' => array('ID' => '(int) autodraft post ID', 'post_ID' => '(int) post ID', 'author_ID' => '(int) author ID', 'title' => '(HTML) The post title.', 'content' => '(HTML) The post content.', 'excerpt' => '(HTML) The post excerpt.', 'preview_URL' => '(string) preview URL for the post', 'modified' => '(ISO 8601 datetime) modified time'), 'example_request' => 'https://public-api.wordpress.com/rest/v1.1/sites/82974409/posts/1/autosave'));
new WPCOM_JSON_API_Autosave_Post_v1_1_Endpoint(array('description' => 'Create a post autosave.', 'group' => '__do_not_document', 'stat' => 'posts:autosave', 'min_version' => '1.1', 'method' => 'POST', 'path' => '/sites/%s/posts/%d/autosave', 'path_labels' => array('$site' => '(int|string) Site ID or domain', '$post_ID' => '(int) The post ID'), 'request_format' => array('content' => '(HTML) The post content.', 'title' => '(HTML) The post title.', 'excerpt' => '(HTML) The post excerpt.'), 'response_format' => array('ID' => '(int) autodraft post ID', 'post_ID' => '(int) post ID', 'preview_URL' => '(string) preview URL for the post', 'modified' => '(ISO 8601 datetime) modified time'), 'example_request' => 'https://public-api.wordpress.com/rest/v1.1/sites/82974409/posts/1/autosave', 'example_request_data' => array('headers' => array('authorization' => 'Bearer YOUR_API_TOKEN'), 'body' => array('title' => 'Howdy', 'content' => 'Hello. I am a test post. I was created by the API'))));
/*
 * Media Endpoints
 */
new WPCOM_JSON_API_List_Media_Endpoint(array('description' => 'Get a list of items in the media library.', 'group' => 'media', 'stat' => 'media', 'method' => 'GET', 'path' => '/sites/%s/media/', 'deprecated' => true, 'new_version' => '1.1', 'max_version' => '1', 'path_labels' => array('$site' => '(int|string) Site ID or domain'), 'query_parameters' => array('number' => '(int=20) The number of media items to return. Limit: 100.', 'offset' => '(int=0) 0-indexed offset.', 'parent_id' => '(int) Default is showing all items. The post where the media item is attached. 0 shows unattached media items.', 'mime_type' => "(string) Default is empty. Filter by mime type (e.g., 'image/jpeg', 'application/pdf'). Partial searches also work (e.g. passing 'image' will search for all image files)."), 'response_format' => array('media' => '(array) Array of media', 'found' => '(int) The number of total results found'), 'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/82974409/media/?number=2', 'example_request_data' => array('headers' => array('authorization' => 'Bearer YOUR_API_TOKEN'))));
new WPCOM_JSON_API_List_Media_v1_1_Endpoint(array('description' => 'Get a list of items in the media library.', 'group' => 'media', 'stat' => 'media', 'min_version' => '1.1', 'max_version' => '1.1', 'method' => 'GET', 'path' => '/sites/%s/media/', 'path_labels' => array('$site' => '(int|string) Site ID or domain'), 'query_parameters' => array('number' => '(int=20) The number of media items to return. Limit: 100.', 'offset' => '(int=0) 0-indexed offset.', 'page' => '(int) Return the Nth 1-indexed page of posts. Takes precedence over the <code>offset</code> parameter.', 'page_handle' => '(string) A page handle, returned from a previous API call as a <code>meta.next_page</code> property. This is the most efficient way to fetch the next page of results.', 'order' => array('DESC' => 'Return files in descending order. For dates, that means newest to oldest.', 'ASC' => 'Return files in ascending order. For dates, that means oldest to newest.'), 'order_by' => array('date' => 'Order by the uploaded time of each file.', 'title' => "Order lexicographically by file titles.", 'ID' => 'Order by media ID.'), 'search' => '(string) Search query.', 'post_ID' => '(int) Default is showing all items. The post where the media item is attached. 0 shows unattached media items.', 'mime_type' => "(string) Default is empty. Filter by mime type (e.g., 'image/jpeg', 'application/pdf'). Partial searches also work (e.g. passing 'image' will search for all image files).", 'after' => '(ISO 8601 datetime) Return media items uploaded after the specified datetime.', 'before' => '(ISO 8601 datetime) Return media items uploaded before the specified datetime.'), 'response_format' => array('media' => '(array) Array of media objects', 'found' => '(int) The number of total results found'), 'example_request' => 'https://public-api.wordpress.com/rest/v1.1/sites/82974409/media', 'example_request_data' => array('headers' => array('authorization' => 'Bearer YOUR_API_TOKEN'))));
new WPCOM_JSON_API_Get_Media_Endpoint(array('description' => 'Get a single media item (by ID).', 'group' => 'media', 'stat' => 'media:1', 'method' => 'GET', 'path' => '/sites/%s/media/%d', 'deprecated' => true, 'new_version' => '1.1', 'max_version' => '1', 'path_labels' => array('$site' => '(int|string) Site ID or domain', '$media_ID' => '(int) The ID of the media item'), 'response_format' => array('id' => '(int) The ID of the media item', 'date' => '(ISO 8601 datetime) The date the media was uploaded', 'parent' => '(int) ID of the post this media is attached to', 'link' => '(string) URL to the file', 'title' => '(string) Filename', 'caption' => '(string) User-provided caption of the file', 'description' => '(string) Description of the file', 'metadata' => '(array) Array of metadata about the file, such as Exif data or sizes'), 'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/82974409/media/934', 'example_request_data' => array('headers' => array('authorization' => 'Bearer YOUR_API_TOKEN'))));
new WPCOM_JSON_API_Get_Media_v1_1_Endpoint(array('description' => 'Get a single media item (by ID).', 'group' => 'media', 'stat' => 'media:1', 'min_version' => '1.1', 'max_version' => '1.1', 'method' => 'GET', 'path' => '/sites/%s/media/%d', 'path_labels' => array('$site' => '(int|string) Site ID or domain', '$media_ID' => '(int) The ID of the media item'), 'response_format' => array('ID' => '(int) The ID of the media item', 'date' => '(ISO 8601 datetime) The date the media was uploaded', 'post_ID' => '(int) ID of the post this media is attached to', 'author_ID' => '(int) ID of the user who uploaded the media', 'URL' => '(string) URL to the file', 'guid' => '(string) Unique identifier', 'file' => '(string) Filename', 'extension' => '(string) File extension', 'mime_type' => '(string) File MIME type', 'title' => '(string) Filename', 'caption' => '(string) User-provided caption of the file', 'description' => '(string) Description of the file', 'alt' => '(string)  Alternative text for image files.', 'thumbnails' => '(object) Media item thumbnail URL options', 'height' => '(int) (Image & video only) Height of the media item', 'width' => '(int) (Image & video only) Width of the media item', 'length' => '(int) (Video & audio only) Duration of the media item, in seconds', 'exif' => '(array) (Image & audio only) Exif (meta) information about the media item', 'videopress_guid' => '(string) (Video only) VideoPress GUID of the video when uploaded on a blog with VideoPress', 'videopress_processing_done' => '(bool) (Video only) If the video is uploaded on a blog with VideoPress, this will return the status of processing on the video.'), 'example_request' => 'https://public-api.wordpress.com/rest/v1.1/sites/82974409/media/934', 'example_request_data' => array('headers' => array('authorization' => 'Bearer YOUR_API_TOKEN'))));
new WPCOM_JSON_API_Upload_Media_Endpoint(array('description' => 'Upload a new media item.', 'group' => 'media', 'stat' => 'media:new', 'method' => 'POST', 'path' => '/sites/%s/media/new', 'deprecated' => true, 'new_version' => '1.1', 'max_version' => '1', 'path_labels' => array('$site' => '(int|string) Site ID or domain'), 'request_format' => array('media' => "(media) An array of media to attach to the post. To upload media, the entire request should be multipart/form-data encoded. Accepts images (image/gif, image/jpeg, image/png) only at this time.<br /><br /><strong>Example</strong>:<br />" . "<code>curl \\<br />--form 'media[]=@/path/to/file.jpg' \\<br />-H 'Authorization: BEARER your-token' \\<br />'https://public-api.wordpress.com/rest/v1/sites/123/media/new'</code>", 'media_urls' => "(array) An array of URLs to upload to the post."), 'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/82974409/media/new/', 'response_format' => array('media' => '(array) Array of uploaded media', 'errors' => '(array) Array of error messages of uploading media failures'), 'example_request_data' => array('headers' => array('authorization' => 'Bearer YOUR_API_TOKEN'), 'body' => array('media_urls' => "https://s.w.org/about/images/logos/codeispoetry-rgb.png"))));
new WPCOM_JSON_API_Upload_Media_v1_1_Endpoint(array('description' => 'Upload a new piece of media.', 'group' => 'media', 'stat' => 'media:new', 'min_version' => '1.1', 'max_version' => '1.1', 'method' => 'POST', 'path' => '/sites/%s/media/new', 'path_labels' => array('$site' => '(int|string) Site ID or domain'), 'request_format' => array('media' => "(media) An array of media to attach to the post. To upload media, the entire request should be multipart/form-data encoded. Accepts  jpg, jpeg, png, gif, pdf, doc, ppt, odt, pptx, docx, pps, ppsx, xls, xlsx, key. Audio and Video may also be available. See <code>allowed_file_types</code> in the options response of the site endpoint.<br /><br /><strong>Example</strong>:<br />" . "<code>curl \\<br />--form 'media[]=@/path/to/file.jpg' \\<br />-H 'Authorization: BEARER your-token' \\<br />'https://public-api.wordpress.com/rest/v1/sites/123/media/new'</code>", 'media_urls' => "(array) An array of URLs to upload to the post. Errors produced by media uploads, if any, will be in `media_errors` in the response.", 'attrs' => "(array) An array of attributes (`title`, `description`, `caption` `alt` for images, `artist` for audio, `album` for audio, and `parent_id`) are supported to assign to the media uploaded via the `media` or `media_urls` properties. You must use a numeric index for the keys of `attrs` which follows the same sequence as `media` and `media_urls`. <br /><br /><strong>Example</strong>:<br />" . "<code>curl \\<br />--form 'media[]=@/path/to/file1.jpg' \\<br />--form 'media_urls[]=http://example.com/file2.jpg' \\<br /> \\<br />--form 'attrs[0][caption]=This will be the caption for file1.jpg' \\<br />--form 'attrs[1][title]=This will be the title for file2.jpg' \\<br />-H 'Authorization: BEARER your-token' \\<br />'https://public-api.wordpress.com/rest/v1/sites/123/posts/new'</code>"), 'response_format' => array('media' => '(array) Array of uploaded media objects', 'errors' => '(array) Array of error messages of uploading media failures'), 'example_request' => 'https://public-api.wordpress.com/rest/v1.1/sites/82974409/media/new', 'example_request_data' => array('headers' => array('authorization' => 'Bearer YOUR_API_TOKEN'), 'body' => array('media_urls' => "https://s.w.org/about/images/logos/codeispoetry-rgb.png"))));
Esempio n. 26
0
 /**
  * Format JS options for the form, to be used with wp_localize_script
  *
  * @return array  Options for our form JS handling
  */
 public function get_js_options()
 {
     global $wp_roles;
     $args = array();
     $connectors = WP_Stream_Connectors::$term_labels['stream_connector'];
     asort($connectors);
     $roles = $wp_roles->roles;
     $roles_arr = array_combine(array_keys($roles), wp_list_pluck($roles, 'name'));
     $default_operators = array('=' => esc_html__('is', 'stream-notifications'), '!=' => esc_html__('is not', 'stream-notifications'), 'in' => esc_html__('is in', 'stream-notifications'), '!in' => esc_html__('is not in', 'stream-notifications'));
     $text_operator = array('=' => esc_html__('is', 'stream-notifications'), '!=' => esc_html__('is not', 'stream-notifications'), 'contains' => esc_html__('contains', 'stream-notifications'), '!contains' => esc_html__('does not contain', 'stream-notifications'), 'starts' => esc_html__('starts with', 'stream-notifications'), 'ends' => esc_html__('ends with', 'stream-notifications'), 'regex' => esc_html__('regex', 'stream-notifications'));
     $numeric_operators = array('=' => esc_html__('equals', 'stream-notifications'), '!=' => esc_html__('not equal', 'stream-notifications'), '<' => esc_html__('less than', 'stream-notifications'), '<=' => esc_html__('equal or less than', 'stream-notifications'), '>' => esc_html__('greater than', 'stream-notifications'), '>=' => esc_html__('equal or greater than', 'stream-notifications'));
     $args['types'] = array('search' => array('title' => esc_html__('Summary', 'stream-notifications'), 'type' => 'text', 'operators' => $text_operator), 'object_id' => array('title' => esc_html__('Object ID', 'stream-notifications'), 'type' => 'text', 'tags' => true, 'operators' => $default_operators), 'author_role' => array('title' => esc_html__('Author Role', 'stream-notifications'), 'type' => 'select', 'multiple' => true, 'operators' => $default_operators, 'options' => $roles_arr), 'author' => array('title' => esc_html__('Author', 'stream-notifications'), 'type' => 'text', 'ajax' => true, 'operators' => $default_operators), 'ip' => array('title' => esc_html__('IP', 'stream-notifications'), 'type' => 'text', 'subtype' => 'ip', 'tags' => true, 'operators' => $default_operators), 'date' => array('title' => esc_html__('Date', 'stream-notifications'), 'type' => 'date', 'operators' => array('=' => esc_html__('is on', 'stream-notifications'), '!=' => esc_html__('is not on', 'stream-notifications'), '<' => esc_html__('is before', 'stream-notifications'), '<=' => esc_html__('is on or before', 'stream-notifications'), '>' => esc_html__('is after', 'stream-notifications'), '>=' => esc_html__('is on or after', 'stream-notifications'))), 'weekday' => array('title' => esc_html__('Day of Week', 'stream-notifications'), 'type' => 'select', 'multiple' => true, 'operators' => $default_operators, 'options' => array_combine(array_map(function ($weekday_index) {
         return sprintf('weekday_%d', $weekday_index % 7);
     }, range(get_option('start_of_week'), get_option('start_of_week') + 6)), array_map(function ($weekday_index) {
         global $wp_locale;
         return $wp_locale->get_weekday($weekday_index % 7);
     }, range(get_option('start_of_week'), get_option('start_of_week') + 6)))), 'connector' => array('title' => esc_html__('Connector', 'stream-notifications'), 'type' => 'select', 'multiple' => true, 'operators' => $default_operators, 'options' => $connectors), 'context' => array('title' => esc_html__('Context', 'stream-notifications'), 'type' => 'select', 'multiple' => true, 'operators' => $default_operators, 'options' => WP_Stream_Connectors::$term_labels['stream_context']), 'action' => array('title' => esc_html__('Action', 'stream-notifications'), 'type' => 'select', 'multiple' => true, 'operators' => $default_operators, 'options' => WP_Stream_Connectors::$term_labels['stream_action']));
     // Connector-based triggers
     $args['special_types'] = array('post' => array('title' => esc_html__('- Post', 'stream-notifications'), 'type' => 'text', 'ajax' => true, 'connector' => 'posts', 'operators' => $default_operators), 'post_title' => array('title' => esc_html__('- Post: Title', 'stream-notifications'), 'type' => 'text', 'connector' => 'posts', 'operators' => $text_operator), 'post_slug' => array('title' => esc_html__('- Post: Slug', 'stream-notifications'), 'type' => 'text', 'connector' => 'posts', 'operators' => $text_operator), 'post_content' => array('title' => esc_html__('- Post: Content', 'stream-notifications'), 'type' => 'text', 'connector' => 'posts', 'operators' => $text_operator), 'post_excerpt' => array('title' => esc_html__('- Post: Excerpt', 'stream-notifications'), 'type' => 'text', 'connector' => 'posts', 'operators' => $text_operator), 'post_author' => array('title' => esc_html__('- Post: Author', 'stream-notifications'), 'type' => 'text', 'ajax' => true, 'connector' => 'posts', 'operators' => $default_operators), 'post_status' => array('title' => esc_html__('- Post: Status', 'stream-notifications'), 'type' => 'select', 'connector' => 'posts', 'options' => wp_list_pluck($GLOBALS['wp_post_statuses'], 'label'), 'operators' => $default_operators), 'post_format' => array('title' => esc_html__('- Post: Format', 'stream-notifications'), 'type' => 'select', 'connector' => 'posts', 'options' => get_post_format_strings(), 'operators' => $default_operators), 'post_parent' => array('title' => esc_html__('- Post: Parent', 'stream-notifications'), 'type' => 'text', 'ajax' => true, 'connector' => 'posts', 'operators' => $default_operators), 'post_thumbnail' => array('title' => esc_html__('- Post: Featured Image', 'stream-notifications'), 'type' => 'select', 'connector' => 'posts', 'options' => array('0' => esc_html__('None', 'stream-notifications'), '1' => esc_html__('Has one', 'stream-notifications')), 'operators' => $default_operators), 'post_comment_status' => array('title' => esc_html__('- Post: Comment Status', 'stream-notifications'), 'type' => 'select', 'connector' => 'posts', 'options' => array('open' => esc_html__('Open', 'stream-notifications'), 'closed' => esc_html__('Closed', 'stream-notifications')), 'operators' => $default_operators), 'post_comment_count' => array('title' => esc_html__('- Post: Comment Count', 'stream-notifications'), 'type' => 'text', 'connector' => 'posts', 'operators' => $numeric_operators), 'user' => array('title' => esc_html__('- User', 'stream-notifications'), 'type' => 'text', 'ajax' => true, 'connector' => 'users', 'operators' => $default_operators), 'user_role' => array('title' => esc_html__('- User: Role', 'stream-notifications'), 'type' => 'select', 'connector' => 'users', 'options' => $roles_arr, 'operators' => $default_operators), 'tax' => array('title' => esc_html__('- Taxonomy', 'stream-notifications'), 'type' => 'text', 'ajax' => true, 'connector' => 'taxonomies', 'operators' => $default_operators), 'term' => array('title' => esc_html__('- Term', 'stream-notifications'), 'type' => 'text', 'ajax' => true, 'connector' => 'taxonomies', 'operators' => $default_operators), 'term_parent' => array('title' => esc_html__('- Term: Parent', 'stream-notifications'), 'type' => 'text', 'ajax' => true, 'connector' => 'taxonomies', 'operators' => $default_operators));
     $args['adapters'] = array();
     foreach (WP_Stream_Notifications::$adapters as $name => $options) {
         $args['adapters'][$name] = array('title' => $options['title'], 'fields' => $options['class']::fields(), 'hints' => $options['class']::hints());
     }
     // Localization
     $args['i18n'] = array('empty_triggers' => esc_html__('You cannot save a rule without any triggers.', 'stream-notifications'), 'invalid_first_trigger' => esc_html__('You cannot save a rule with an empty first trigger.', 'stream-notifications'), 'ajax_error' => esc_html__('There was an error submitting your request, please try again.', 'stream-notifications'), 'confirm_reset' => esc_html__('Are you sure you want to reset occurrences for this rule? This cannot be undone.', 'stream-notifications'));
     return apply_filters('stream_notification_js_args', $args);
 }
 /**
  * Edit a post.
  *
  * @since 1.5.0
  *
  * @param array $args Method parameters.
  * @return bool|IXR_Error True on success.
  */
 public function mw_editPost($args)
 {
     $this->escape($args);
     $post_ID = (int) $args[0];
     $username = $args[1];
     $password = $args[2];
     $content_struct = $args[3];
     $publish = isset($args[4]) ? $args[4] : 0;
     if (!($user = $this->login($username, $password))) {
         return $this->error;
     }
     /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
     do_action('xmlrpc_call', 'metaWeblog.editPost');
     $postdata = get_post($post_ID, ARRAY_A);
     // If there is no post data for the give post id, stop
     // now and return an error. Other wise a new post will be
     // created (which was the old behavior).
     if (!$postdata || empty($postdata['ID'])) {
         return new IXR_Error(404, __('Invalid post ID.'));
     }
     if (!current_user_can('edit_post', $post_ID)) {
         return new IXR_Error(401, __('Sorry, you do not have the right to edit this post.'));
     }
     // Use wp.editPost to edit post types other than post and page.
     if (!in_array($postdata['post_type'], array('post', 'page'))) {
         return new IXR_Error(401, __('Invalid post type'));
     }
     // Thwart attempt to change the post type.
     if (!empty($content_struct['post_type']) && $content_struct['post_type'] != $postdata['post_type']) {
         return new IXR_Error(401, __('The post type may not be changed.'));
     }
     // Check for a valid post format if one was given
     if (isset($content_struct['wp_post_format'])) {
         $content_struct['wp_post_format'] = sanitize_key($content_struct['wp_post_format']);
         if (!array_key_exists($content_struct['wp_post_format'], get_post_format_strings())) {
             return new IXR_Error(404, __('Invalid post format'));
         }
     }
     $this->escape($postdata);
     $ID = $postdata['ID'];
     $post_content = $postdata['post_content'];
     $post_title = $postdata['post_title'];
     $post_excerpt = $postdata['post_excerpt'];
     $post_password = $postdata['post_password'];
     $post_parent = $postdata['post_parent'];
     $post_type = $postdata['post_type'];
     $menu_order = $postdata['menu_order'];
     // Let WordPress manage slug if none was provided.
     $post_name = "";
     $post_name = $postdata['post_name'];
     if (isset($content_struct['wp_slug'])) {
         $post_name = $content_struct['wp_slug'];
     }
     // Only use a password if one was given.
     if (isset($content_struct['wp_password'])) {
         $post_password = $content_struct['wp_password'];
     }
     // Only set a post parent if one was given.
     if (isset($content_struct['wp_page_parent_id'])) {
         $post_parent = $content_struct['wp_page_parent_id'];
     }
     // Only set the menu_order if it was given.
     if (isset($content_struct['wp_page_order'])) {
         $menu_order = $content_struct['wp_page_order'];
     }
     $page_template = null;
     if (!empty($content_struct['wp_page_template']) && 'page' == $post_type) {
         $page_template = $content_struct['wp_page_template'];
     }
     $post_author = $postdata['post_author'];
     // Only set the post_author if one is set.
     if (isset($content_struct['wp_author_id']) && $user->ID != $content_struct['wp_author_id']) {
         switch ($post_type) {
             case 'post':
                 if (!current_user_can('edit_others_posts')) {
                     return new IXR_Error(401, __('You are not allowed to change the post author as this user.'));
                 }
                 break;
             case 'page':
                 if (!current_user_can('edit_others_pages')) {
                     return new IXR_Error(401, __('You are not allowed to change the page author as this user.'));
                 }
                 break;
             default:
                 return new IXR_Error(401, __('Invalid post type'));
                 break;
         }
         $post_author = $content_struct['wp_author_id'];
     }
     if (isset($content_struct['mt_allow_comments'])) {
         if (!is_numeric($content_struct['mt_allow_comments'])) {
             switch ($content_struct['mt_allow_comments']) {
                 case 'closed':
                     $comment_status = 'closed';
                     break;
                 case 'open':
                     $comment_status = 'open';
                     break;
                 default:
                     $comment_status = get_option('default_comment_status');
                     break;
             }
         } else {
             switch ((int) $content_struct['mt_allow_comments']) {
                 case 0:
                 case 2:
                     $comment_status = 'closed';
                     break;
                 case 1:
                     $comment_status = 'open';
                     break;
                 default:
                     $comment_status = get_option('default_comment_status');
                     break;
             }
         }
     }
     if (isset($content_struct['mt_allow_pings'])) {
         if (!is_numeric($content_struct['mt_allow_pings'])) {
             switch ($content_struct['mt_allow_pings']) {
                 case 'closed':
                     $ping_status = 'closed';
                     break;
                 case 'open':
                     $ping_status = 'open';
                     break;
                 default:
                     $ping_status = get_option('default_ping_status');
                     break;
             }
         } else {
             switch ((int) $content_struct["mt_allow_pings"]) {
                 case 0:
                     $ping_status = 'closed';
                     break;
                 case 1:
                     $ping_status = 'open';
                     break;
                 default:
                     $ping_status = get_option('default_ping_status');
                     break;
             }
         }
     }
     if (isset($content_struct['title'])) {
         $post_title = $content_struct['title'];
     }
     if (isset($content_struct['description'])) {
         $post_content = $content_struct['description'];
     }
     $post_category = array();
     if (isset($content_struct['categories'])) {
         $catnames = $content_struct['categories'];
         if (is_array($catnames)) {
             foreach ($catnames as $cat) {
                 $post_category[] = get_cat_ID($cat);
             }
         }
     }
     if (isset($content_struct['mt_excerpt'])) {
         $post_excerpt = $content_struct['mt_excerpt'];
     }
     $post_more = isset($content_struct['mt_text_more']) ? $content_struct['mt_text_more'] : null;
     $post_status = $publish ? 'publish' : 'draft';
     if (isset($content_struct["{$post_type}_status"])) {
         switch ($content_struct["{$post_type}_status"]) {
             case 'draft':
             case 'pending':
             case 'private':
             case 'publish':
                 $post_status = $content_struct["{$post_type}_status"];
                 break;
             default:
                 $post_status = $publish ? 'publish' : 'draft';
                 break;
         }
     }
     $tags_input = isset($content_struct['mt_keywords']) ? $content_struct['mt_keywords'] : null;
     if ('publish' == $post_status) {
         if ('page' == $post_type && !current_user_can('publish_pages')) {
             return new IXR_Error(401, __('Sorry, you do not have the right to publish this page.'));
         } else {
             if (!current_user_can('publish_posts')) {
                 return new IXR_Error(401, __('Sorry, you do not have the right to publish this post.'));
             }
         }
     }
     if ($post_more) {
         $post_content = $post_content . "<!--more-->" . $post_more;
     }
     $to_ping = null;
     if (isset($content_struct['mt_tb_ping_urls'])) {
         $to_ping = $content_struct['mt_tb_ping_urls'];
         if (is_array($to_ping)) {
             $to_ping = implode(' ', $to_ping);
         }
     }
     // Do some timestamp voodoo
     if (!empty($content_struct['date_created_gmt'])) {
         // We know this is supposed to be GMT, so we're going to slap that Z on there by force
         $dateCreated = rtrim($content_struct['date_created_gmt']->getIso(), 'Z') . 'Z';
     } elseif (!empty($content_struct['dateCreated'])) {
         $dateCreated = $content_struct['dateCreated']->getIso();
     }
     if (!empty($dateCreated)) {
         $post_date = get_date_from_gmt(iso8601_to_datetime($dateCreated));
         $post_date_gmt = iso8601_to_datetime($dateCreated, 'GMT');
     } else {
         $post_date = $postdata['post_date'];
         $post_date_gmt = $postdata['post_date_gmt'];
     }
     // We've got all the data -- post it:
     $newpost = compact('ID', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt', 'comment_status', 'ping_status', 'post_date', 'post_date_gmt', 'to_ping', 'post_name', 'post_password', 'post_parent', 'menu_order', 'post_author', 'tags_input', 'page_template');
     $result = wp_update_post($newpost, true);
     if (is_wp_error($result)) {
         return new IXR_Error(500, $result->get_error_message());
     }
     if (!$result) {
         return new IXR_Error(500, __('Sorry, your entry could not be edited. Something wrong happened.'));
     }
     // Only posts can be sticky
     if ($post_type == 'post' && isset($content_struct['sticky'])) {
         if ($content_struct['sticky'] == true) {
             stick_post($post_ID);
         } elseif ($content_struct['sticky'] == false) {
             unstick_post($post_ID);
         }
     }
     if (isset($content_struct['custom_fields'])) {
         $this->set_custom_fields($post_ID, $content_struct['custom_fields']);
     }
     if (isset($content_struct['wp_post_thumbnail'])) {
         // empty value deletes, non-empty value adds/updates
         if (empty($content_struct['wp_post_thumbnail'])) {
             delete_post_thumbnail($post_ID);
         } else {
             if (set_post_thumbnail($post_ID, $content_struct['wp_post_thumbnail']) === false) {
                 return new IXR_Error(404, __('Invalid attachment ID.'));
             }
         }
         unset($content_struct['wp_post_thumbnail']);
     }
     // Handle enclosures
     $thisEnclosure = isset($content_struct['enclosure']) ? $content_struct['enclosure'] : null;
     $this->add_enclosure_if_new($post_ID, $thisEnclosure);
     $this->attach_uploads($ID, $post_content);
     // Handle post formats if assigned, validation is handled
     // earlier in this function
     if (isset($content_struct['wp_post_format'])) {
         set_post_format($post_ID, $content_struct['wp_post_format']);
     }
     /**
      * Fires after a post has been successfully updated via the XML-RPC MovableType API.
      *
      * @since 3.4.0
      *
      * @param int   $post_ID ID of the updated post.
      * @param array $args    An array of arguments to update the post.
      */
     do_action('xmlrpc_call_success_mw_editPost', $post_ID, $args);
     return true;
 }
Esempio n. 28
0
 function ajax_acf_location($options = array())
 {
     // defaults
     $defaults = array('key' => null, 'value' => null, 'param' => null);
     // Is AJAX call?
     if (isset($_POST['action']) && $_POST['action'] == "acf_location") {
         $options = array_merge($defaults, $_POST);
     } else {
         $options = array_merge($defaults, $options);
     }
     // some case's have the same outcome
     if ($options['param'] == "page_parent") {
         $options['param'] = "page";
     }
     $choices = array();
     $optgroup = false;
     switch ($options['param']) {
         case "post_type":
             $choices = get_post_types(array('public' => true));
             unset($choices['attachment']);
             break;
         case "page":
             $pages = get_pages('sort_column=menu_order&sort_order=desc');
             foreach ($pages as $page) {
                 $value = '';
                 $ancestors = get_ancestors($page->ID, 'page');
                 if ($ancestors) {
                     foreach ($ancestors as $a) {
                         $value .= '– ';
                     }
                 }
                 $value .= get_the_title($page->ID);
                 $choices[$page->ID] = $value;
             }
             break;
         case "page_type":
             $choices = array('parent' => 'Parent Page', 'child' => 'Child Page');
             break;
         case "page_template":
             $choices = array('default' => 'Default Template');
             $templates = get_page_templates();
             foreach ($templates as $k => $v) {
                 $choices[$v] = $k;
             }
             break;
         case "post":
             $posts = get_posts(array('numberposts' => '-1'));
             foreach ($posts as $v) {
                 $choices[$v->ID] = $v->post_title;
             }
             break;
         case "post_category":
             $category_ids = get_all_category_ids();
             foreach ($category_ids as $cat_id) {
                 $cat_name = get_cat_name($cat_id);
                 $choices[$cat_id] = $cat_name;
             }
             break;
         case "post_format":
             /*$choices = array(
             			'0'			=>	'Standard',
             			'aside'		=>	'Aside',
             			'link'		=>	'Link',
             			'gallery'	=>	'Gallery',
             			'status'	=>	'Status',
             			'quote'		=>	'Quote',
             			'image'		=>	'Image',
             		);*/
             $choices = get_post_format_strings();
             break;
         case "user_type":
             global $wp_roles;
             $choices = $wp_roles->get_names();
             break;
         case "options_page":
             $choices = array('Options' => 'Options');
             $custom = apply_filters('acf_register_options_page', array());
             if (!empty($custom)) {
                 $choices = array();
                 foreach ($custom as $c) {
                     $choices[$c['title']] = $c['title'];
                 }
             }
             break;
         case "taxonomy":
             $choices = $this->get_taxonomies_for_select();
             $optgroup = true;
             break;
     }
     $this->create_field(array('type' => 'select', 'name' => 'location[rules][' . $options['key'] . '][value]', 'value' => $options['value'], 'choices' => $choices, 'optgroup' => $optgroup));
     // ajax?
     if (isset($_POST['action']) && $_POST['action'] == "acf_location") {
         die;
     }
 }
Esempio n. 29
0
/**
 * Returns a pretty, translated version of a post format slug
 *
 * @since 3.1.0
 *
 * @param string $slug A post format slug
 * @return string The translated post format name
 */
function get_post_format_string($slug)
{
    $strings = get_post_format_strings();
    if (!$slug) {
        return $strings['standard'];
    } else {
        return isset($strings[$slug]) ? $strings[$slug] : '';
    }
}
 /**
  * Returns array of selectable pages 
  * 
  */
 protected static function selectable_pages($plugin_id, $type)
 {
     // $type = [include] [exclude]
     global $wp_post_types, $wp_taxonomies;
     $values_to_select = q2w3_include_obj::page_selectors($plugin_id);
     if ($type == 'exclude') {
         array_shift($values_to_select);
     }
     $options = get_option(q2w3_inc_manager::ID);
     if (!$options) {
         $options = q2w3_inc_manager::$default_options;
     }
     if ($options['taxonomies']['post_format']['enable']) {
         $formats_orig = get_post_format_strings();
         foreach ($formats_orig as $fkey => $fname) {
             $formats['post_format_' . $fkey] = __('PF', $plugin_id) . ': ' . $fname;
         }
         $values_to_select[__('Post Formats')] = $formats;
     }
     foreach ($options['post_types'] as $post_type => $params) {
         $pages = NULL;
         if ($params['enable'] == 'on' && !in_array($post_type, q2w3_inc_manager::$restricted_post_types)) {
             $post_type_name = $wp_post_types[$post_type]->labels->name;
             $selectors = array($post_type . '_all' => __('All', $plugin_id) . ' ' . $post_type_name);
             if (version_compare($GLOBALS['wp_version'], '3.1.0', '>=') && $post_type != 'page') {
                 $selectors = array_merge($selectors, array('post_type_archive_' . $post_type => __('Archive', $plugin_id) . ': ' . $post_type_name));
             }
             if ($params['expand'] == 'on') {
                 $pages = q2w3_table_func::select_post_type($post_type);
             }
             if (!empty($pages)) {
                 $selectors = array_merge($selectors, $pages);
             }
             $values_to_select[$post_type_name] = $selectors;
         }
     }
     foreach ($options['taxonomies'] as $taxonomy => $params) {
         $pages = NULL;
         if ($params['enable'] == 'on' && !in_array($taxonomy, q2w3_inc_manager::$restricted_taxonomies)) {
             $taxonomy_name = $wp_taxonomies[$taxonomy]->labels->name;
             $selectors = array($taxonomy . '_all' => __('All', $plugin_id) . ' ' . $taxonomy_name);
             if ($params['expand'] == 'on') {
                 $pages = q2w3_table_func::select_taxonomy($taxonomy);
             }
             if (!empty($pages)) {
                 $selectors = array_merge($selectors, $pages);
             }
             $values_to_select[$taxonomy_name] = $selectors;
         }
     }
     /*$pages = q2w3_table_func::wp_pages();
     		
     		if (!empty($pages)) $values_to_select[__('Pages', $plugin_id)] = $pages;
     		
     		$pages = q2w3_table_func::wp_categories();
     		
     		if (!empty($pages)) $values_to_select[__('Categories', $plugin_id)] = $pages;
     		
     		$pages = q2w3_table_func::wp_tags();
     				
     		if (!empty($pages)) $values_to_select[__('Tags', $plugin_id)] = $pages;
     		
     		$pages = q2w3_table_func::wp_posts();
     		
     		if (!empty($pages)) $values_to_select[__('Posts', $plugin_id)] = $pages;*/
     return $values_to_select;
 }