function setUp()
 {
     $this->attachment = create_attachment();
     $this->image_data = wp_get_attachment_metadata($this->attachment);
     $this->upload_url = wp_upload_dir()['baseurl'];
     $this->image = '<img src="' . $this->upload_url . '/' . $this->image_data['file'] . '" class="alignnone">';
     add_filter('rwp_edit_attributes', array($this, 'edit_attributes'));
 }
 function setUp()
 {
     update_option('rwp_added_filters', array('the_content', 'post_thumbnail_html'));
     $this->attachment = create_attachment();
     $this->image_data = wp_get_attachment_metadata($this->attachment);
     $upload_url = wp_upload_dir()['baseurl'];
     $image = '<img src="' . $upload_url . '/' . $this->image_data['file'] . '">';
     $this->page = wp_insert_post(array('post_name' => 'test', 'post_type' => 'page', 'post_content' => $image, 'post_status' => 'publish'));
     $this->upload_url = wp_upload_dir()['baseurl'];
     $this->image_url = wp_upload_dir()['baseurl'] . '/' . $this->image_data['file'];
     $this->mock_image_dimentions();
 }
 function test_debug_mode()
 {
     $attachment = create_attachment('debug');
     $image_data = wp_get_attachment_metadata($attachment);
     $upload_url = wp_upload_dir()['baseurl'];
     $image = '<img src="' . $upload_url . '/' . $image_data['file'] . '">';
     $post = wp_insert_post(array('post_name' => 'test', 'post_content' => $image, 'post_status' => 'publish'));
     update_option('rwp_debug_mode', 'on');
     $post = get_post($post);
     $post = trim(apply_filters('the_content', $post->post_content));
     update_option('rwp_debug_mode', 'off');
     $debug_html_comment = array("<!--", "### RWP Debug ###", "Attachment ID: {$attachment}", "Image sizes: thumbnail, medium, large, post-thumbnail, full", "Image width: 2448", "Image height: 3264", "Image sizes found: thumbnail, medium, large, full", "Images found: ", "- thumbnail: http://example.org/wp-content/uploads/debug-480x640.jpg, ", "- medium: http://example.org/wp-content/uploads/debug-600x800.jpg, ", "- large: http://example.org/wp-content/uploads/debug-1024x1365.jpg, ", "- full: http://example.org/wp-content/uploads/debug.jpg", "Largest size that should be used: http://example.org/wp-content/uploads/2014/10/debug.jpg", "Media queries: ", "- Use medium when min-width: 480px, ", "- Use large when min-width: 600px, ", "- Use full when min-width: 1024px", "-->");
     $debug_html_comment = implode("\n", $debug_html_comment);
     $expected = '<p>' . $debug_html_comment . '<img srcset="http://example.org/wp-content/uploads/debug-480x640.jpg 480w, http://example.org/wp-content/uploads/debug-600x800.jpg 600w, http://example.org/wp-content/uploads/debug-1024x1365.jpg 1024w, http://example.org/wp-content/uploads/debug.jpg 2448w" sizes="(min-width: 1024px) 2448px, (min-width: 600px) 1024px, (min-width: 480px) 600px, 480px"></p>';
     $this->assertEquals($expected, $post);
 }
Пример #4
0
 function setUp()
 {
     $this->attachment = create_attachment();
 }
Пример #5
0
 function setUp()
 {
     $this->attachment = create_attachment();
     update_option('rwp_picturefill', 'off');
 }
Пример #6
0
                 $ps = $db->select('attachments', 'COUNT(id)', $data, 'post_id=:id GROUP BY post_id', 1);
                 $num_attachments = $ps->fetchColumn();
                 $can_upload = $panther_user['g_attach_files'] == '1' && ($cur_post['upload'] == '1' || $cur_post['upload'] == '') ? true : false;
                 if ($can_upload && $num_attachments == $panther_user['g_max_attachments']) {
                     $can_upload = false;
                 }
                 $max_size = $panther_user['g_max_size'] == '0' && $panther_user['g_attach_files'] == '1' ? $panther_config['o_max_upload_size'] : $panther_user['g_max_size'];
                 if ($can_upload && $_FILES['attached_file']['size'] > $max_size) {
                     $can_upload = false;
                 }
                 if (!check_file_extension($_FILES['attached_file']['name'])) {
                     $can_upload = false;
                 }
             }
             if ($can_upload) {
                 if (!create_attachment($_FILES['attached_file']['name'], $_FILES['attached_file']['type'], $_FILES['attached_file']['size'], $_FILES['attached_file']['tmp_name'], $id, strlen($message))) {
                     message($lang_post['Attachment error']);
                 }
             } else {
                 // Remove file as it's either dangerous or they've attempted to URL hack. Either way, there's no need for it.
                 unlink($_FILES['attached_file']['tmp_name']);
             }
         }
     }
     ($hook = get_extensions('edit_after_edit')) ? eval($hook) : null;
     if ($add_poll) {
         redirect(panther_link($panther_url['poll_add'], array($cur_post['tid'])), $lang_post['Edit redirect']);
     } else {
         redirect(panther_link($panther_url['post'], array($id)), $lang_post['Edit redirect']);
     }
 }