Ejemplo n.º 1
0
 /**
  * gallery shortcode sort fix
  * - get the gallery shortcode
  * - extract the ids
  * - save the ids as menu_order for the current images.
  *
  * @link   http://wordpress.org/support/topic/when-is-menu_order-set-for-attachments#post-3816412
  *
  * @param int $id
  *
  * @access public
  */
 public function galleryMenuOrderFix($id)
 {
     //$regex_pattern = get_shortcode_regex();
     $regex_matches = array();
     $content = Filter::post_var('content');
     preg_match('/\\[gallery[^\\]]*\\](.*)/', stripslashes($content), $regex_matches);
     if (substr($regex_matches[0], 1, 7) == 'gallery') {
         $attributes = array();
         preg_match('/"([^"]+)"/', $regex_matches[0], $attributes);
         $attributes = $attributes[1];
     }
     $ids = explode(',', $attributes);
     $images = get_posts(array('post_parent' => $id, 'numberposts' => '-1', 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'orderby' => 'menu_order ID', 'order' => 'ASC'));
     if (!empty($images)) {
         foreach ($images as $attachment_id => $attachment) {
             if (\in_array($attachment->ID, $ids)) {
                 $update_post = array();
                 $update_post['ID'] = $attachment->ID;
                 $update_post['menu_order'] = \array_search($attachment->ID, $ids);
                 \wp_update_post($update_post);
             }
         }
     }
 }
Ejemplo n.º 2
0
 /**
  *
  * request is $_POST data
  *
  * @access private
  * @return boolean if the request is $_GET return true else false
  */
 private function isPost($name)
 {
     //TODO has_var
     if (\is_null(Filter::post_var($name))) {
         return false;
     }
     return true;
 }