Beispiel #1
0
 function getPostsBy($field, $args)
 {
     global $wp_xmlrpc_server, $wpdb;
     // use core xml-rpc to handle error conditions
     if (!is_array($args) || count($args) < 4) {
         return $wp_xmlrpc_server->wp_getPosts($args);
     }
     if ($field == 'date') {
         // if a valide date is not passed return the default xml-rpc get posts
         $since = strtotime($args[3]);
         if ($since < 1) {
             return $wp_xmlrpc_server->wp_getPosts($args);
         }
         $since = date('Y-m-d H:i:s', $since);
         $where = $wpdb->prepare('(post_date >= %s OR post_modified >= %s) AND ', $since, $since);
         $order = 'post_date DESC';
         $limit = '';
     } else {
         if (!(int) $args[3]) {
             return $wp_xmlrpc_server->wp_getPosts($args);
         }
         $where = $wpdb->prepare('ID >= %d AND ', $args[3]);
         $order = 'ID ASC';
         $limit = 'LIMIT 0, 10';
     }
     // get post ids
     $post_types = Scribe_SEO::get_option('post-types');
     if (empty($post_types) || !is_array($post_types)) {
         return array();
     }
     $post_list = $wpdb->get_col("SELECT ID FROM {$wpdb->posts} WHERE {$where} post_type IN ('" . implode("','", $post_types) . "') AND post_status != 'auto-draft' ORDER BY {$order} {$limit}");
     if (!$post_list) {
         return array();
     }
     $posts = array();
     foreach ($post_list as $post_id) {
         $post_args = array_slice($args, 0, 3);
         $post_args[3] = $post_id;
         $post_args[5] = true;
         $post = self::getPost($post_args);
         if (is_array($post)) {
             $posts[] = $post;
         }
     }
     return $posts;
 }
Beispiel #2
0
 /**
  * Helper function that returns a setting value from this form's settings
  * field for use in form fields.
  *
  * @since 0.1.0
  *
  * @param string $key Field key
  * @return string Field value
  */
 protected function get_field_value($key, $subkey = null)
 {
     $setting = Scribe_SEO::get_option($key, $this->settings_field);
     if ($subkey === null) {
         return $setting;
     }
     if (isset($setting[$subkey])) {
         return $setting[$subkey];
     }
     return '';
 }