get() public method

offset and rows per page can also be passed for pagination.
public get ( array $columns, $offset = false, $per_page = false, $order_by = 'id desc' ) : array
$columns array
return array
コード例 #1
0
 /**
  * Function to handle the callback request by the FFMPEG encoding server
  *
  * @since 1.0
  */
 public function handle_callback()
 {
     require_once ABSPATH . 'wp-admin/includes/image.php';
     if (isset($_REQUEST['job_id']) && isset($_REQUEST['download_url'])) {
         $has_thumbs = isset($_POST['thumbs']) ? true : false;
         $flag = false;
         global $wpdb;
         $model = new RTDBModel('rtm_media_meta', false, 10, true);
         $meta_details = $model->get(array('meta_value' => $_REQUEST['job_id'], 'meta_key' => 'rtmedia-encoding-job-id'));
         if (!isset($meta_details[0])) {
             $id = intval($_REQUEST["rt_id"]);
         } else {
             $id = $meta_details[0]->media_id;
         }
         if (isset($id) && is_numeric($id)) {
             $model = new RTMediaModel();
             $media = $model->get_media(array('id' => $id), 0, 1);
             $this->media_author = $media[0]->media_author;
             $attachment_id = $media[0]->media_id;
             //error_log(var_export($_POST,true));
             update_post_meta($attachment_id, 'rtmedia_encode_response', $_POST);
             if ($has_thumbs) {
                 $cover_art = $this->add_media_thumbnails($attachment_id);
             }
             if (isset($_POST['format']) && $_POST['format'] == 'thumbnails') {
                 die;
             }
             $this->uploaded["context"] = $media[0]->context;
             $this->uploaded["context_id"] = $media[0]->context_id;
             $this->uploaded["media_author"] = $media[0]->media_author;
             $attachemnt_post = get_post($attachment_id);
             $download_url = urldecode(urldecode($_REQUEST['download_url']));
             //error_log($download_url);
             $new_wp_attached_file_pathinfo = pathinfo($download_url);
             $post_mime_type = $new_wp_attached_file_pathinfo['extension'] == 'mp4' ? 'video/mp4' : 'audio/mp3';
             try {
                 $file_bits = file_get_contents($download_url);
             } catch (Exception $e) {
                 $flag = $e->getMessage();
             }
             if ($file_bits) {
                 unlink(get_attached_file($attachment_id));
                 add_filter('upload_dir', array($this, 'upload_dir'));
                 $upload_info = wp_upload_bits($new_wp_attached_file_pathinfo['basename'], null, $file_bits);
                 //error_log(var_dump($upload_info));
                 $wpdb->update($wpdb->posts, array('guid' => $upload_info['url'], 'post_mime_type' => $post_mime_type), array('ID' => $attachment_id));
                 $old_wp_attached_file = get_post_meta($attachment_id, '_wp_attached_file', true);
                 $old_wp_attached_file_pathinfo = pathinfo($old_wp_attached_file);
                 update_post_meta($attachment_id, '_wp_attached_file', str_replace($old_wp_attached_file_pathinfo['basename'], $new_wp_attached_file_pathinfo['basename'], $old_wp_attached_file));
                 //                        $media_entry = new BPMediaHostWordpress($attachment_id);
                 //                        $activity_content = str_replace($old_wp_attached_file_pathinfo['basename'], $new_wp_attached_file_pathinfo['basename'], $media_entry->get_media_activity_content());
                 //                        $wpdb->update($wpdb->prefix . 'bp_activity', array('content' => $activity_content), array('id' => $media[0]->activity_id));
                 // Check if uplaod is through activity upload
                 //update_post_meta($attachment_id, 'rtmedia_encode_response', $_POST);
                 $activity_id = $media[0]->activity_id;
                 if ($activity_id) {
                     $content = $wpdb->get_var("SELECT content FROM {$wpdb->base_prefix}bp_activity WHERE id = {$activity_id}");
                     $activity_content = str_replace($attachemnt_post->guid, $upload_info['url'], $content);
                     $wpdb->update($wpdb->base_prefix . 'bp_activity', array('content' => $activity_content), array('id' => $activity_id));
                 }
             } else {
                 $flag = __('Could not read file.', 'buddypress-media');
                 error_log($flag);
             }
         } else {
             $flag = __('Something went wrong. The required attachment id does not exists. It must have been deleted.', 'buddypress-media');
             error_log($flag);
         }
         $this->update_usage($this->api_key);
         if (isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] == '4.30.110.155') {
             $mail = true;
         } else {
             $mail = false;
         }
         if ($flag && $mail) {
             $download_link = esc_url(add_query_arg(array('job_id' => $_GET['job_id'], 'download_url' => $_GET['download_url']), home_url()));
             $subject = __('rtMedia Encoding: Download Failed', 'buddypress-media');
             $message = sprintf(__('<p><a href="%s">Media</a> was successfully encoded but there was an error while downloading:</p>
                     <p><code>%s</code></p>
                     <p>You can <a href="%s">retry the download</a>.</p>', 'buddypress-media'), get_edit_post_link($attachment_id), $flag, $download_link);
             $users = get_users(array('role' => 'administrator'));
             if ($users) {
                 foreach ($users as $user) {
                     $admin_email_ids[] = $user->user_email;
                 }
                 add_filter('wp_mail_content_type', create_function('', 'return "text/html";'));
                 wp_mail($admin_email_ids, $subject, $message);
             }
             echo $flag;
         } elseif ($flag) {
             echo $flag;
         } else {
             _e("Done", 'buddypress-media');
         }
         die;
     }
 }
コード例 #2
0
 function get($columns, $offset = false, $per_page = false, $order_by = 'activity_id DESC')
 {
     $columns['blog_id'] = get_current_blog_id();
     return parent::get($columns, $offset, $per_page, $order_by);
 }