/**
 *
 * SETTINGS PAGE
 *
 */
function wr2x_settings_page()
{
    global $wr2x_settings_api;
    echo '<div class="wrap">';
    jordy_meow_donation(true);
    $method = wr2x_getoption("method", "wr2x_advanced", 'retina.js');
    echo "<div id='icon-options-general' class='icon32'><br></div><h2>WP Retina 2x";
    by_jordy_meow();
    echo "</h2>";
    if ($method == 'retina.js') {
        echo "<p><span style='color: blue;'>" . __("Current method:", 'wp-retina-2x') . " <u>" . __("Client side", 'wp-retina-2x') . "</u>.</span>";
    }
    if ($method == 'Retina-Images') {
        echo "<p><span style='color: blue;'>" . __("Current method:", 'wp-retina-2x') . " <u>" . __("Server side", 'wp-retina-2x') . "</u>.</span>";
        if (defined('MULTISITE') && MULTISITE == true) {
            if (get_site_option('ms_files_rewriting')) {
                // MODIFICATION: Craig Foster
                // 'ms_files_rewriting' support
                echo " <span style='color: red;'>" . __("By the way, you are using a <b>WordPress Multi-Site installation</b>! You must edit your .htaccess manually and add '<b>RewriteRule ^files/(.+) wp-content/plugins/wp-retina-2x/wr2x_image.php?ms=true&file=\$1 [L]</b>' as the first RewriteRule if you want the server-side to work.", 'wp-retina-2x') . "</span>";
            } else {
                echo " <span style='color: red;'>" . __("By the way, you are using a <b>WordPress Multi-Site installation</b>! You must edit your .htaccess manually and add '<b>RewriteRule ^(wp-content/.+\\.(png|gif|jpg|jpeg|bmp|PNG|GIF|JPG|JPEG|BMP)) wp-content/plugins/wp-retina-2x/wr2x_image.php?ms=true&file=\$1 [L]</b>' as the first RewriteRule if you want the server-side to work.", 'wp-retina-2x') . "</span>";
            }
        }
        echo "</p>";
        if (!get_option('permalink_structure')) {
            echo "<p><span style='color: red;'>" . __("The permalinks are not enabled. They need to be enabled in order to use the server-side method.", 'wp-retina-2x') . "</span>";
        }
    }
    //settings_errors();
    $wr2x_settings_api->show_navigation();
    $wr2x_settings_api->show_forms();
    echo '</div>';
    jordy_meow_footer();
}
/**
 *
 * SETTINGS PAGE
 *
 */
function wpmc_settings_page()
{
    global $wpmc_settings_api;
    echo '<div class="wrap">';
    jordy_meow_donation();
    echo "<div id='icon-options-general' class='icon32'><br></div><h2>WP Media Cleaner";
    by_jordy_meow();
    echo "</h2>";
    $wpmc_settings_api->show_navigation();
    $wpmc_settings_api->show_forms();
    echo '</div>';
    jordy_meow_footer();
}
function wpr2x_wp_retina_2x()
{
    $view = isset($_GET['view']) ? $_GET['view'] : 'issues';
    $paged = isset($_GET['paged']) ? $_GET['paged'] : 1;
    $s = isset($_GET['s']) ? $_GET['s'] : null;
    $issues = $count = 0;
    $sizes = wr2x_get_image_sizes();
    $posts_per_page = 15;
    // TODO: HOW TO GET THE NUMBER OF MEDIA PER PAGES? IT IS NOT get_option('posts_per_page');
    $issues = wr2x_get_issues();
    $ignored = wr2x_get_ignores();
    ?>
	<div class='wrap'>
	<?php 
    jordy_meow_donation(true);
    ?>
	<div id="icon-upload" class="icon32"><br></div>
	<h2>WP Retina 2x <?php 
    by_jordy_meow();
    ?>
</h2>

	<?php 
    if ($view == 'issues') {
        global $wpdb;
        $totalcount = $wpdb->get_var($wpdb->prepare("\n\t\t\tSELECT COUNT(*)\n\t\t\tFROM {$wpdb->posts} p\n\t\t\tWHERE post_status = 'inherit'\n\t\t\tAND post_type = 'attachment'\n\t\t\tAND post_title LIKE %s\n\t\t\tAND ( post_mime_type = 'image/jpeg' OR\n\t\t\tpost_mime_type = 'image/png' OR\n\t\t\tpost_mime_type = 'image/gif' )\n\t\t", '%' . $s . '%'));
        $postin = count($issues) < 1 ? array(-1) : $issues;
        $query = new WP_Query(array('post_status' => 'inherit', 'post_type' => 'attachment', 'post__in' => $postin, 'paged' => $paged, 'posts_per_page' => $posts_per_page, 's' => $s));
    } else {
        if ($view == 'ignored') {
            global $wpdb;
            $totalcount = $wpdb->get_var($wpdb->prepare("\n\t\t\tSELECT COUNT(*)\n\t\t\tFROM {$wpdb->posts} p\n\t\t\tWHERE post_status = 'inherit'\n\t\t\tAND post_type = 'attachment'\n\t\t\tAND post_title LIKE %s\n\t\t\tAND ( post_mime_type = 'image/jpeg' OR\n\t\t\tpost_mime_type = 'image/jpg' OR\n\t\t\tpost_mime_type = 'image/png' OR\n\t\t\tpost_mime_type = 'image/gif' )\n\t\t", '%' . $s . '%'));
            $postin = count($ignored) < 1 ? array(-1) : $ignored;
            $query = new WP_Query(array('post_status' => 'inherit', 'post_type' => 'attachment', 'post__in' => $postin, 'paged' => $paged, 'posts_per_page' => $posts_per_page, 's' => $s));
        } else {
            $query = new WP_Query(array('post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image/jpeg,image/gif,image/jpg,image/png', 'paged' => $paged, 'posts_per_page' => $posts_per_page, 's' => $s));
            //$s
            $totalcount = $query->found_posts;
        }
    }
    $issues_count = count($issues);
    // If 'search', then we need to clean-up the issues count
    if ($s && $issues_count > 0) {
        global $wpdb;
        $issues_count = $wpdb->get_var($wpdb->prepare("\n\t\t\tSELECT COUNT(*)\n\t\t\tFROM {$wpdb->posts} p\n\t\t\tWHERE id IN ( " . implode(',', $issues) . " )\n\t\t\tAND post_title LIKE %s\n\t\t", '%' . $s . '%'));
    }
    $results = array();
    $count = $query->found_posts;
    $pagescount = $query->max_num_pages;
    foreach ($query->posts as $post) {
        $info = wr2x_retina_info($post->ID);
        array_push($results, array('post' => $post, 'info' => $info));
    }
    ?>

	<div style='background: #FFF; padding: 5px; border-radius: 4px; height: 28px; box-shadow: 0px 0px 6px #C2C2C2;'>
		
		<!-- GENERATE ALL -->
		<a id='wr2x_generate_button_all' onclick='wr2x_generate_all()' class='button-primary' style='float: left;'><img style='position: relative; top: 3px; left: -2px; margin-right: 3px; width: 16px; height: 16px;' src='<?php 
    echo trailingslashit(WP_PLUGIN_URL) . trailingslashit('wp-retina-2x/img');
    ?>
photo-album--plus.png' /><?php 
    _e("Generate", 'wp-retina-2x');
    ?>
</a>
		
		<!-- SEARCH -->
		<form id="posts-filter" action="upload.php" method="get">
			<p class="search-box" style='margin-left: 5px; float: left;'>
				<input type="search" name="s" value="<?php 
    echo $s ? $s : "";
    ?>
">
				<input type="hidden" name="page" value="wp-retina-2x">
				<input type="hidden" name="view" value="<?php 
    echo $view;
    ?>
">
				<input type="hidden" name="paged" value="<?php 
    echo $paged;
    ?>
">
				<input type="submit" class="button" value="Search">
			</p>
		</form>

		<!-- REMOVE BUTTON ALL -->
		<a id='wr2x_remove_button_all' onclick='wr2x_delete_all()' class='button button-red' style='float: right;'><img style='position: relative; top: 3px; left: -2px; margin-right: 3px; width: 16px; height: 16px;' src='<?php 
    echo trailingslashit(WP_PLUGIN_URL) . trailingslashit('wp-retina-2x/img');
    ?>
burn.png' /><?php 
    _e("Delete all @2x", 'wp-retina-2x');
    ?>
</a>

		<!-- REFRESH -->
		<a id='wr2x_refresh' href='?page=wp-retina-2x&view=issues&refresh=true' class='button-primary' style='float: right; margin-right: 5px;'><img style='position: relative; top: 3px; left: -2px; margin-right: 3px; width: 16px; height: 16px;' src='<?php 
    echo trailingslashit(WP_PLUGIN_URL) . trailingslashit('wp-retina-2x/img');
    ?>
refresh.png' /><?php 
    _e("Refresh issues", 'wp-retina-2x');
    ?>
</a>

		<!-- PROGRESS -->
		<span style='margin-left: 12px; font-size: 15px; top: 5px; position: relative; color: #747474;' id='wr2x_progression'></span>
		
	</div>

	<?php 
    if (isset($_GET['refresh']) ? $_GET['refresh'] : 0) {
        echo "<div class='updated' style='margin-top: 20px;'><p>";
        _e("Issues has been refreshed.", 'wp-retina-2x');
        echo "</p></div>";
    }
    ?>
	
	<p><?php 
    _e("You can upload/replace the images by drag & drop on the grid.", 'wp-retina-2x');
    ?>
</p>

	<div id='wr2x-pages'>
	<?php 
    echo paginate_links(array('base' => '?page=wp-retina-2x&s=' . urlencode($s) . '&view=' . $view . '%_%', 'current' => $paged, 'format' => '&paged=%#%', 'total' => $pagescount, 'prev_next' => false));
    ?>
	</div>
	
	<ul class="subsubsub">
		<li class="all"><a <?php 
    if ($view == 'all') {
        echo "class='current'";
    }
    ?>
 href='?page=wp-retina-2x&s=<?php 
    echo $s;
    ?>
&view=all'><?php 
    _e("All", 'wp-retina-2x');
    ?>
</a><span class="count">(<?php 
    echo $totalcount;
    ?>
)</span></li> |
		<li class="all"><a <?php 
    if ($view == 'issues') {
        echo "class='current'";
    }
    ?>
 href='?page=wp-retina-2x&s=<?php 
    echo $s;
    ?>
&view=issues'><?php 
    _e("Issues", 'wp-retina-2x');
    ?>
</a><span class="count">(<?php 
    echo $issues_count;
    ?>
)</span></li> |
		<li class="all"><a <?php 
    if ($view == 'ignored') {
        echo "class='current'";
    }
    ?>
 href='?page=wp-retina-2x&s=<?php 
    echo $s;
    ?>
&view=ignored'><?php 
    _e("Ignored", 'wp-retina-2x');
    ?>
</a><span class="count">(<?php 
    echo count($ignored);
    ?>
)</span></li>
	</ul>
	<table class='wp-list-table widefat fixed media'>
		<thead><tr>
			<?php 
    echo "<th style='width: 64px;''></th>";
    echo "<th style='font-size: 11px; font-family: Verdana;'>" . __("Title", 'wp-retina-2x') . "</th>";
    $ignore_cols = wr2x_getoption("ignore_sizes", "wr2x_basics", array());
    foreach ($sizes as $name => $attr) {
        if (!in_array($name, $ignore_cols)) {
            echo "<th style='width: 80px; font-size: 11px; font-family: Verdana;' class='manage-column'>" . $name . "</th>";
        }
    }
    echo "<th style='font-size: 11px; font-family: Verdana; width: 88px;'>" . __("Actions", 'wp-retina-2x') . "</th>";
    echo "<th style='font-size: 11px; font-family: Verdana; width: 70px;'></th>";
    ?>
		</tr></thead>
		<tbody>
			<?php 
    foreach ($results as $index => $attr) {
        $meta = wp_get_attachment_metadata($attr['post']->ID);
        // Let's clean the issues status
        if ($view != 'issues') {
            wr2x_update_issue_status($attr['post']->ID, $issues, $attr['info']);
        }
        if (isset($meta) && isset($meta['width'])) {
            $original_width = $meta['width'];
            $original_height = $meta['height'];
        }
        $attachmentsrc = wp_get_attachment_image_src($attr['post']->ID, 'thumbnail');
        echo "<tr class='wr2x-file-row' postId='" . $attr['post']->ID . "'>";
        echo "<td class='wr2x-image'><img style='max-width: 42px; max-height: 42px;' src='" . $attachmentsrc[0] . "' /></td>";
        echo "<td class='wr2x-title'><a style='position: relative; top: -2px;' href='media.php?attachment_id=" . $attr['post']->ID . "&action=edit'>" . $attr['post']->post_title . '<br />' . "<span style='font-size: 9px; line-height: 10px; display: block;'>" . $original_width . "×" . $original_height . "</span>";
        "</a></td>";
        foreach ($sizes as $aindex => $aval) {
            if (in_array($aindex, $ignore_cols)) {
                continue;
            }
            $aval = isset($attr['info']) && isset($attr['info'][$aindex]) ? $attr['info'][$aindex] : null;
            echo "<td id='wr2x_" . $aindex . "_" . $attr['post']->ID . "'>";
            if (is_array($aval)) {
                echo "<img title='Please upload a bigger original image.' style='margin-top: 3px; width: 16px; height: 16px;' src='" . trailingslashit(WP_PLUGIN_URL) . trailingslashit('wp-retina-2x/img') . "exclamation.png' />" . "<span style='font-size: 9px; margin-left: 5px; position: relative; top: -10px;'><br />< " . $aval['width'] . "×" . $aval['height'] . "</span>";
            } else {
                if ($aval == 'EXISTS') {
                    echo "<img style='margin-top: 3px; width: 16px; height: 16px;' src='" . trailingslashit(WP_PLUGIN_URL) . trailingslashit('wp-retina-2x/img') . "tick-circle.png' />";
                } else {
                    if ($aval == 'PENDING') {
                        echo "<img title='Click on \"Generate\".' style='margin-top: 3px; width: 16px; height: 16px;' src='" . trailingslashit(WP_PLUGIN_URL) . trailingslashit('wp-retina-2x/img') . "clock.png' />";
                    } else {
                        if ($aval == 'MISSING') {
                            echo "<img title='The file related to this size is missing.' style='margin-top: 3px; width: 16px; height: 16px;' src='" . trailingslashit(WP_PLUGIN_URL) . trailingslashit('wp-retina-2x/img') . "cross-small.png' />";
                        } else {
                            if ($aval == 'IGNORED') {
                                echo "<img title='Retina disabled.' style='margin-top: 3px; width: 16px; height: 16px;' src='" . trailingslashit(WP_PLUGIN_URL) . trailingslashit('wp-retina-2x/img') . "prohibition-small.png' />";
                            } else {
                                echo "<span style='position: relative; top: 3px;'>" . $aval . "</span>";
                            }
                        }
                    }
                }
            }
            echo "</td>";
        }
        echo "<td><a style='position: relative; top: 0px;' onclick='wr2x_generate(" . $attr['post']->ID . ", true)' id='wr2x_generate_button_" . $attr['post']->ID . "' class='button-secondary'>" . __("GENERATE", 'wp-retina-2x') . "</a></td>";
        if (!wr2x_is_ignore($attr['post']->ID)) {
            echo "<td><a style='position: relative; top: 0px;' href='?page=wp-retina-2x&view=" . $view . "&paged=" . $paged . "&ignore=" . $attr['post']->ID . "' id='wr2x_generate_button_" . $attr['post']->ID . "' class='button-secondary'>" . __("IGNORE", 'wp-retina-2x') . "</a></td>";
        }
        echo "</tr>";
    }
    ?>
		</tbody>
	</table>
	</div>

	<?php 
    jordy_meow_footer();
}
示例#4
0
function wpr2x_wp_retina_2x()
{
    $view = isset($_GET['view']) ? $_GET['view'] : 'issues';
    $paged = isset($_GET['paged']) ? $_GET['paged'] : 1;
    $s = isset($_GET['s']) && !empty($_GET['s']) ? sanitize_text_field($_GET['s']) : null;
    $issues = $count = 0;
    $posts_per_page = 15;
    // TODO: HOW TO GET THE NUMBER OF MEDIA PER PAGES? IT IS NOT get_option('posts_per_page');
    $issues = wr2x_get_issues();
    $ignored = wr2x_get_ignores();
    echo '<div class="wrap">';
    jordy_meow_donation(true);
    echo "<h1>Retina";
    by_jordy_meow();
    echo "</h1>";
    if (wr2x_is_pro() && $view == 'issues') {
        global $wpdb;
        $totalcount = $wpdb->get_var($wpdb->prepare("\n\t\t\tSELECT COUNT(*)\n\t\t\tFROM {$wpdb->posts} p\n\t\t\tWHERE post_status = 'inherit'\n\t\t\tAND post_type = 'attachment'" . wr2x_create_sql_if_wpml_original() . "\n\t\t\tAND post_title LIKE %s\n\t\t\tAND ( post_mime_type = 'image/jpeg' OR\n\t\t\tpost_mime_type = 'image/png' OR\n\t\t\tpost_mime_type = 'image/gif' )\n\t\t", '%' . $s . '%'));
        $postin = count($issues) < 1 ? array(-1) : $issues;
        $query = new WP_Query(array('post_status' => 'inherit', 'post_type' => 'attachment', 'post__in' => $postin, 'paged' => $paged, 'posts_per_page' => $posts_per_page, 's' => $s));
    } else {
        if (wr2x_is_pro() && $view == 'ignored') {
            global $wpdb;
            $totalcount = $wpdb->get_var($wpdb->prepare("\n\t\t\tSELECT COUNT(*)\n\t\t\tFROM {$wpdb->posts} p\n\t\t\tWHERE post_status = 'inherit'\n\t\t\tAND post_type = 'attachment'" . wr2x_create_sql_if_wpml_original() . "\n\t\t\tAND post_title LIKE %s\n\t\t\tAND ( post_mime_type = 'image/jpeg' OR\n\t\t\tpost_mime_type = 'image/jpg' OR\n\t\t\tpost_mime_type = 'image/png' OR\n\t\t\tpost_mime_type = 'image/gif' )\n\t\t", '%' . $s . '%'));
            $postin = count($ignored) < 1 ? array(-1) : $ignored;
            $query = new WP_Query(array('post_status' => 'inherit', 'post_type' => 'attachment', 'post__in' => $postin, 'paged' => $paged, 'posts_per_page' => $posts_per_page, 's' => $s));
        } else {
            $query = new WP_Query(array('post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image/jpeg,image/gif,image/jpg,image/png', 'paged' => $paged, 'posts_per_page' => $posts_per_page, 's' => $s));
            //$s
            $totalcount = $query->found_posts;
        }
    }
    $issues_count = count($issues);
    // If 'search', then we need to clean-up the issues count
    if ($s && $issues_count > 0) {
        global $wpdb;
        $issues_count = $wpdb->get_var($wpdb->prepare("\n\t\t\tSELECT COUNT(*)\n\t\t\tFROM {$wpdb->posts} p\n\t\t\tWHERE id IN ( " . implode(',', $issues) . " )" . wr2x_create_sql_if_wpml_original() . "\n\t\t\tAND post_title LIKE %s\n\t\t", '%' . $s . '%'));
    }
    $results = array();
    $count = $query->found_posts;
    $pagescount = $query->max_num_pages;
    foreach ($query->posts as $post) {
        $info = wr2x_retina_info($post->ID);
        array_push($results, array('post' => $post, 'info' => $info));
    }
    ?>

	<div style='background: #FFF; padding: 5px; border-radius: 4px; height: 28px; box-shadow: 0px 0px 6px #C2C2C2;'>

		<!-- REFRESH -->
		<a id='wr2x_refresh' href='?page=wp-retina-2x&view=issues&refresh=true' class='button' style='float: left;'><img style='position: relative; top: 3px; left: -2px; margin-right: 3px; width: 16px; height: 16px;' src='<?php 
    echo plugin_dir_url(__FILE__);
    ?>
img/refresh.png' /><?php 
    _e("Refresh", 'wp-retina-2x');
    ?>
</a>

		<!-- SEARCH -->
		<form id="posts-filter" action="upload.php" method="get">
			<p class="search-box" style='margin-left: 5px; float: left;'>
				<input type="search" name="s" value="<?php 
    echo $s ? $s : "";
    ?>
">
				<input type="hidden" name="page" value="wp-retina-2x">
				<input type="hidden" name="view" value="<?php 
    echo $view;
    ?>
">
				<input type="hidden" name="paged" value="<?php 
    echo $paged;
    ?>
">
				<input type="submit" class="button" value="Search">
			</p>
		</form>

		<!-- REMOVE BUTTON ALL -->
		<a id='wr2x_remove_button_all' onclick='wr2x_delete_all()' class='button button-red' style='float: right;'><img style='position: relative; top: 3px; left: -2px; margin-right: 3px; width: 16px; height: 16px;' src='<?php 
    echo plugin_dir_url(__FILE__);
    ?>
img/burn.png' /><?php 
    _e("Bulk Delete", 'wp-retina-2x');
    ?>
</a>

		<!-- GENERATE ALL -->
		<a id='wr2x_generate_button_all' onclick='wr2x_generate_all()' class='button-primary' style='float: right; margin-right: 5px;'><img style='position: relative; top: 3px; left: -2px; margin-right: 3px; width: 16px; height: 16px;' src='<?php 
    echo plugin_dir_url(__FILE__);
    ?>
img/photo-album--plus.png' /><?php 
    _e("Bulk Generate", 'wp-retina-2x');
    ?>
</a>


		<!-- PROGRESS -->
		<span style='margin-left: 12px; font-size: 13px; top: 5px; position: relative; color: #24547C; font-weight: bold;' id='wr2x_progression'></span>

	</div>

	<?php 
    if (isset($_GET['clearlogs']) ? $_GET['clearlogs'] : 0) {
        echo "<div class='updated' style='margin-top: 20px;'><p>";
        _e("The logs have been cleared.", 'wp-retina-2x');
        echo "</p></div>";
    }
    $active_sizes = wr2x_get_active_image_sizes();
    $full_size_needed = wr2x_getoption("full_size", "wr2x_basics", false);
    $max_width = 0;
    $max_height = 0;
    foreach ($active_sizes as $name => $active_size) {
        if ($active_size['height'] != 9999 && $active_size['height'] > $max_height) {
            $max_height = $active_size['height'];
        }
        if ($active_size['width'] != 9999 && $active_size['width'] > $max_width) {
            $max_width = $active_size['width'];
        }
    }
    $max_width = $max_width * 2;
    $max_height = $max_height * 2;
    $upload_max_size = ini_get('upload_max_filesize');
    ?>

	<p>
		<?php 
    printf(__('The full-size images should have a resolution of <b>%d×%d</b> at least for the plugin to be able generate the <b>%d retina images</b> required by your website.', 'wp-retina-2x'), $max_width, $max_height, count($active_sizes));
    ?>
		<?php 
    if ($full_size_needed) {
        printf(__("You <b>also need</b> to upload a retina image for the Full-Size image (might be <b>%d×%d</b>).", 'wp-retina-2x'), $max_width * 2, $max_height * 2);
    }
    ?>
		<?php 
    _e("You can upload or replace the images by drag & drop.", 'wp-retina-2x');
    ?>
		<?php 
    printf(__("Your PHP configuration allows uploads of <b>%dMB</b> maximum.", 'wp-retina-2x'), $upload_max_size);
    ?>

		<?php 
    if (file_exists(plugin_dir_path(__FILE__) . '/wp-retina-2x.log')) {
        printf(__('The <a target="_blank" href="%s/wp-retina-2x.log">log file</a> is available. You can also <a href="?page=wp-retina-2x&view=issues&clearlogs=true">clear</a> it.', 'wp-retina-2x'), plugin_dir_url(__FILE__));
    }
    ?>
	</p>

	<?php 
    if (!wr2x_is_pro()) {
        echo '<div class="updated"><p>';
        echo __('<b>Only Pro users have access to the features of this dashboard.</b> As a standard user, the dashboard allow you to Bulk Generate, Bulk Delete and access the Retina Logs. If you wish to stay a standard user and never see this dashboard aver again, you can hide it in the settings.<br /><br />The main features of the Pro version are: filter by <b>Issues</b> or Ignored, <b>Ignore</b> media (from the retina process), <b>Details</b> for more information, <b>replace</b> a full-size directly by drag & drop, upload a retina version of the full-size, various options and direct support by the developer. The serial key for the Pro has to be inserted in your WP Settings > Retina > Pro tab. Thank you for your support :)<br /><br /><a class="button-primary" href="http://apps.meow.fr/wp-retina-2x/" target="_blank">Get the serial key for the Pro</a>', 'wp-retina-2x');
        echo '</p></div>';
    }
    ?>

	<div id='wr2x-pages'>
	<?php 
    echo paginate_links(array('base' => '?page=wp-retina-2x&s=' . urlencode($s) . '&view=' . $view . '%_%', 'current' => $paged, 'format' => '&paged=%#%', 'total' => $pagescount, 'prev_next' => false));
    ?>
	</div>

	<ul class="subsubsub">
		<li class="all"><a <?php 
    if ($view == 'all') {
        echo "class='current'";
    }
    ?>
 href='?page=wp-retina-2x&s=<?php 
    echo $s;
    ?>
&view=all'><?php 
    _e("All", 'wp-retina-2x');
    ?>
</a><span class="count">(<?php 
    echo $totalcount;
    ?>
)</span></li> |

		<?php 
    if (wr2x_is_pro()) {
        ?>

		<li class="all"><a <?php 
        if ($view == 'issues') {
            echo "class='current'";
        }
        ?>
 href='?page=wp-retina-2x&s=<?php 
        echo $s;
        ?>
&view=issues'><?php 
        _e("Issues", 'wp-retina-2x');
        ?>
</a><span class="count">(<?php 
        echo $issues_count;
        ?>
)</span></li> |
		<li class="all"><a <?php 
        if ($view == 'ignored') {
            echo "class='current'";
        }
        ?>
 href='?page=wp-retina-2x&s=<?php 
        echo $s;
        ?>
&view=ignored'><?php 
        _e("Ignored", 'wp-retina-2x');
        ?>
</a><span class="count">(<?php 
        echo count($ignored);
        ?>
)</span></li>

		<?php 
    } else {
        ?>

		<li class="all"><span><?php 
        _e("Issues", 'wp-retina-2x');
        ?>
</span> <span class="count">(<?php 
        echo $issues_count;
        ?>
)</span></li> |
		<li class="all"><span><?php 
        _e("Ignored", 'wp-retina-2x');
        ?>
</span> <span class="count">(<?php 
        echo count($ignored);
        ?>
)</span></li>

		<?php 
    }
    ?>


	</ul>
	<table class='wp-list-table widefat fixed media wr2x-table'>
		<thead><tr>
			<?php 
    echo "<th style='width: 56px;'>Thumbnail</th>";
    echo "<th style=' width: 360px;'>" . __("Base image", 'wp-retina-2x') . "</th>";
    echo "<th style=''>" . __("Media Sizes<br />Retina-ized", 'wp-retina-2x') . "</th>";
    echo "<th style=''>" . __("Full-Size<br/><b>Replace</b>", 'wp-retina-2x') . "</th>";
    echo "<th style=''>" . __("Full-Size Retina", 'wp-retina-2x') . "</th>";
    echo "<th style=''>" . __("Full-Size Retina<br/><b>Upload</b>", 'wp-retina-2x') . "</th>";
    ?>
		</tr></thead>
		<tbody>
			<?php 
    foreach ($results as $index => $attr) {
        $post = $attr['post'];
        $info = $attr['info'];
        $meta = wp_get_attachment_metadata($post->ID);
        // Let's clean the issues status
        if ($view != 'issues') {
            wr2x_update_issue_status($post->ID, $issues, $info);
        }
        if (isset($meta) && isset($meta['width'])) {
            $original_width = $meta['width'];
            $original_height = $meta['height'];
        }
        $attachmentsrc = wp_get_attachment_image_src($post->ID, 'thumbnail');
        echo "<tr class='wr2x-file-row' postId='" . $post->ID . "'>";
        echo "<td class='wr2x-image wr2x-info-thumbnail'><img src='" . $attachmentsrc[0] . "' /></td>";
        echo "<td class='wr2x-title'><a href='media.php?attachment_id=" . $post->ID . "&action=edit'>" . ($post->post_title ? $post->post_title : '<i>Untitled</i>') . '</a><br />' . "<span class='resolution'>Full-Size: <span class='" . ($original_width < $max_width ? "red" : "") . "'>" . $original_width . "</span>×<span class='" . ($original_height < $max_height ? "red" : "") . "'>" . $original_height . "</span></span>";
        echo "<div class='actions'>";
        echo "<a style='position: relative;' onclick='wr2x_generate(" . $post->ID . ", true)' id='wr2x_generate_button_" . $post->ID . "' class='wr2x-button'>" . __("GENERATE", 'wp-retina-2x') . "</a>";
        if (!wr2x_is_ignore($post->ID)) {
            echo " <a href='?page=wp-retina-2x&view=" . $view . "&paged=" . $paged . "&ignore=" . $post->ID . "' id='wr2x_generate_button_" . $post->ID . "' class='wr2x-button wr2x-button-ignore'>" . __("IGNORE", 'wp-retina-2x') . "</a>";
        }
        echo " <a style='position: relative;' class='wr2x-button wr2x-button-view'>" . __("DETAILS", 'wp-retina-2x') . "</a>";
        echo "</div></td>";
        // Media Sizes Retina-ized
        echo '<td id="wr2x-info-' . $post->ID . '" style="padding-top: 10px;" class="wr2x-info">';
        echo wpr2x_html_get_basic_retina_info($post, $info);
        echo "</td>";
        if (wr2x_is_pro()) {
            // Full-Size Replace
            echo "<td class='wr2x-fullsize-replace'><div class='wr2x-dragdrop'></div>";
            echo "</td>";
            // Full-Size Retina
            echo '<td id="wr2x-info-full-' . $post->ID . '" class="wr2x-image wr2x-info-full">';
            echo wpr2x_html_get_basic_retina_info_full($post->ID, $info);
            echo "</td>";
            // Full-Size Retina Upload
            echo "<td class='wr2x-fullsize-retina-upload'>";
            echo "<div class='wr2x-dragdrop'></div>";
            echo "</td>";
        } else {
            echo "<td colspan='3' style='text-align: center; background: #F9F9F9;'><small><br />PRO VERSION ONLY</small></td>";
        }
        echo "</tr>";
    }
    ?>
		</tbody>
	</table>
	</div>

	<div id="wr2x-modal-info-backdrop" style="display: none;">
	</div>

	<div id="wr2x-modal-info" style="display: none;" tabindex="1">
		<div class="close">X</div>
		<h2 style="margin-top: 0px;">Retina Details</h2>
		<div class="loading">
			<img src="<?php 
    echo plugin_dir_url(__FILE__);
    ?>
img/loading.gif" />
		</div>
		<div class="content">
		</div>
	</div>

	<?php 
    jordy_meow_footer();
}
function wpmc_screen()
{
    ?>
	<div class='wrap'>
		<?php 
    jordy_meow_donation();
    ?>
		<div id="icon-upload" class="icon32"><br></div>
		<h2>WP Media Cleaner <?php 
    by_jordy_meow();
    ?>
</h2>

		<?php 
    global $wpdb;
    $posts_per_page = 15;
    $view = isset($_GET['view']) ? sanitize_text_field($_GET['view']) : "issues";
    $paged = isset($_GET['paged']) ? sanitize_text_field($_GET['paged']) : 1;
    $reset = isset($_GET['reset']) ? $_GET['reset'] : 0;
    if ($reset) {
        wpmc_reset();
    }
    $s = isset($_GET['s']) ? sanitize_text_field($_GET['s']) : null;
    $table_name = $wpdb->prefix . "wpmcleaner";
    $issues_count = $wpdb->get_var("SELECT COUNT(*) FROM {$table_name} WHERE ignored = 0 AND deleted = 0");
    $total_size = $wpdb->get_var("SELECT SUM(size) FROM {$table_name} WHERE ignored = 0 AND deleted = 0");
    $trash_total_size = $wpdb->get_var("SELECT SUM(size) FROM {$table_name} WHERE ignored = 0 AND deleted = 1");
    $ignored_count = $wpdb->get_var("SELECT COUNT(*) FROM {$table_name} WHERE ignored = 1");
    $deleted_count = $wpdb->get_var("SELECT COUNT(*) FROM {$table_name} WHERE deleted = 1");
    if ($view == 'deleted') {
        $items_count = $deleted_count;
        $items = $wpdb->get_results($wpdb->prepare("SELECT id, type, postId, path, size, ignored, deleted, issue \n\t\t\t\t\tFROM {$table_name} WHERE ignored = 0 AND deleted = 1 AND path LIKE %s \n\t\t\t\t\tORDER BY time \n\t\t\t\t\tDESC LIMIT %d, %d", '%' . $s . '%', ($paged - 1) * $posts_per_page, $posts_per_page), OBJECT);
    } else {
        if ($view == 'ignored') {
            $items_count = $ignored_count;
            $items = $wpdb->get_results($wpdb->prepare("SELECT id, type, postId, path, size, ignored, deleted, issue \n\t\t\t\t\tFROM {$table_name} \n\t\t\t\t\tWHERE ignored = 1 AND deleted = 0 AND path LIKE %s \n\t\t\t\t\tORDER BY time \n\t\t\t\t\tDESC LIMIT %d, %d", '%' . $s . '%', ($paged - 1) * $posts_per_page, $posts_per_page), OBJECT);
        } else {
            $items_count = $issues_count;
            $items = $wpdb->get_results($wpdb->prepare("SELECT id, type, postId, path, size, ignored, deleted, issue \n\t\t\t\t\tFROM {$table_name} \n\t\t\t\t\tWHERE ignored = 0 AND deleted = 0  AND path LIKE %s\n\t\t\t\t\tORDER BY time \n\t\t\t\t\tDESC LIMIT %d, %d", '%' . $s . '%', ($paged - 1) * $posts_per_page, $posts_per_page), OBJECT);
        }
    }
    ?>

		<style>
			#wpmc-pages {
				float: right;
				position: relative;
				top: 12px;
			}

			#wpmc-pages a {
				text-decoration: none;
				border: 1px solid black;
				padding: 2px 5px;
				border-radius: 4px;
				background: #E9E9E9;
				color: lightslategrey;
				border-color: #BEBEBE;
			}

			#wpmc-pages .current {
				font-weight: bold;
			}
		</style>
		
		<div style='margin-top: 0px; background: #FFF; padding: 5px; border-radius: 4px; height: 28px; box-shadow: 0px 0px 6px #C2C2C2;'>
			
			<!-- SCAN -->
			<?php 
    if ($view != 'deleted') {
        ?>
				<a id='wpmc_scan' onclick='wpmc_scan()' class='button-primary' style='float: left;'><img style='position: relative; top: 3px; left: -2px; margin-right: 3px; width: 16px; height: 16px;' src='<?php 
        echo trailingslashit(WP_PLUGIN_URL) . trailingslashit('wp-media-cleaner/img');
        ?>
search.png' /><?php 
        _e("Scan", 'wp-media-cleaner');
        ?>
</a>
			<?php 
    }
    ?>

			<!-- DELETE SELECTED -->		
			<a id='wpmc_delete' onclick='wpmc_delete()' class='button' style='float: left; margin-left: 5px;'><img style='position: relative; top: 3px; left: -2px; margin-right: 3px; width: 16px; height: 16px;' src='<?php 
    echo trailingslashit(WP_PLUGIN_URL) . trailingslashit('wp-media-cleaner/img');
    ?>
delete.png' /><?php 
    _e("Delete", 'wp-media-cleaner');
    ?>
</a>
			<?php 
    if ($view == 'deleted') {
        ?>
				<a id='wpmc_recover' onclick='wpmc_recover()' class='button-secondary' style='float: left; margin-left: 5px;'><img style='position: relative; top: 3px; left: -2px; margin-right: 3px; width: 16px; height: 16px;' src='<?php 
        echo trailingslashit(WP_PLUGIN_URL) . trailingslashit('wp-media-cleaner/img');
        ?>
pills.png' /><?php 
        _e("Recover", 'wp-media-cleaner');
        ?>
</a>
			<?php 
    }
    ?>

			<!-- IGNORE SELECTED -->		
			<a id='wpmc_ignore' onclick='wpmc_ignore()' class='button' style='float: left; margin-left: 5px;'><img style='position: relative; top: 3px; left: -2px; margin-right: 3px; width: 16px; height: 16px;' src='<?php 
    echo trailingslashit(WP_PLUGIN_URL) . trailingslashit('wp-media-cleaner/img');
    ?>
tick.png' /><?php 
    _e("Ignore", 'wp-media-cleaner');
    ?>
</a>

			<!-- RESET -->
			<?php 
    if ($view != 'deleted') {
        ?>
				<a id='wpmc_reset' href='?page=wp-media-cleaner&reset=1' class='button-primary' style='float: right; margin-left: 5px;'><img style='position: relative; top: 3px; left: -2px; margin-right: 3px; width: 16px; height: 16px;' src='<?php 
        echo trailingslashit(WP_PLUGIN_URL) . trailingslashit('wp-media-cleaner/img');
        ?>
burn.png' /><?php 
        _e("Reset", 'wp-media-cleaner');
        ?>
</a>
			<?php 
    }
    ?>

			<!-- DELETE ALL -->
			<?php 
    if ($view == 'deleted') {
        ?>
				<a id='wpmc_recover_all' onclick='wpmc_recover_all()' class='button-primary' style='float: right; margin-left: 5px;'><img style='position: relative; top: 3px; left: -2px; margin-right: 3px; width: 16px; height: 16px;' src='<?php 
        echo trailingslashit(WP_PLUGIN_URL) . trailingslashit('wp-media-cleaner/img');
        ?>
pills.png' /><?php 
        _e("Recover all", 'wp-media-cleaner');
        ?>
</a>
				<a id='wpmc_delete_all' onclick='wpmc_delete_all(true)' class='button button-red' style='float: right; margin-left: 5px;'><img style='position: relative; top: 3px; left: -2px; margin-right: 3px; width: 16px; height: 16px;' src='<?php 
        echo trailingslashit(WP_PLUGIN_URL) . trailingslashit('wp-media-cleaner/img');
        ?>
trash.png' /><?php 
        _e("Empty trash", 'wp-media-cleaner');
        ?>
</a>				
			<?php 
    } else {
        ?>
				<a id='wpmc_delete_all' onclick='wpmc_delete_all()' class='button button-red' style='float: right; margin-left: 5px;'><img style='position: relative; top: 3px; left: -2px; margin-right: 3px; width: 16px; height: 16px;' src='<?php 
        echo trailingslashit(WP_PLUGIN_URL) . trailingslashit('wp-media-cleaner/img');
        ?>
delete.png' /><?php 
        _e("Delete all", 'wp-media-cleaner');
        ?>
</a>
			<?php 
    }
    ?>

			<form id="posts-filter" action="upload.php" method="get" style='float: right;'>
				<p class="search-box" style='margin-left: 5px; float: left;'>
					<input type="search" name="s" style="width: 120px;" value="<?php 
    echo $s ? $s : "";
    ?>
">
					<input type="hidden" name="page" value="wp-media-cleaner">
					<input type="hidden" name="view" value="<?php 
    echo $view;
    ?>
">
					<input type="hidden" name="paged" value="<?php 
    echo $paged;
    ?>
">
					<input type="submit" class="button" value="Search"><span style='border-right: #A2A2A2 solid 1px; margin-left: 5px; margin-right: 3px;'>&nbsp;</span>
				</p>
			</form>

			<!-- PROGRESS -->
			<span style='margin-left: 12px; font-size: 15px; top: 5px; position: relative; color: #747474;' id='wpmc_progression'></span>	

		</div>

		<p>
			<?php 
    $scan_files = wpmc_getoption('scan_files', 'wpmc_basics', true);
    $scan_media = wpmc_getoption('scan_media', 'wpmc_basics', true);
    echo "<p>";
    echo "Deleted files will be moved to the 'uploads/wpmc-trash' directory. Please backup your database and files.";
    if (!$scan_files && !$scan_media) {
        echo "<span style='color: red;'>";
        _e(" Scan is not enabled for either the files or the medias. Please check Settings > WP Media Cleaner.", 'wp-media-cleaner');
        echo "</span>";
    }
    if ($scan_media) {
        _e(" If you delete an item of the type MEDIA, the database entry for it (Media Library) will be deleted permanently.", 'wp-media-cleaner');
    }
    ?>
			There are <b><?php 
    echo $issues_count;
    ?>
 issue(s)</b> with your files, accounting for <b><?php 
    echo number_format($total_size / 1000000, 2);
    ?>
 MB</b>. Your trash contains <b><?php 
    echo number_format($trash_total_size / 1000000, 2);
    ?>
 MB.</b>
		</p>

		<div id='wpmc-pages'>
		<?php 
    echo paginate_links(array('base' => '?page=wp-media-cleaner&s=' . urlencode($s) . '&view=' . $view . '%_%', 'current' => $paged, 'format' => '&paged=%#%', 'total' => ceil($items_count / $posts_per_page), 'prev_next' => false));
    ?>
		</div>

		<ul class="subsubsub">
			<li class="all"><a <?php 
    if ($view == 'issues') {
        echo "class='current'";
    }
    ?>
 href='?page=wp-media-cleaner&s=<?php 
    echo $s;
    ?>
&view=issues'><?php 
    _e("Issues", 'wp-media-cleaner');
    ?>
</a><span class="count">(<?php 
    echo $issues_count;
    ?>
)</span></li> |
			<li class="all"><a <?php 
    if ($view == 'ignored') {
        echo "class='current'";
    }
    ?>
 href='?page=wp-media-cleaner&s=<?php 
    echo $s;
    ?>
&view=ignored'><?php 
    _e("Ignored", 'wp-media-cleaner');
    ?>
</a><span class="count">(<?php 
    echo $ignored_count;
    ?>
)</span></li> |
			<li class="all"><a <?php 
    if ($view == 'deleted') {
        echo "class='current'";
    }
    ?>
 href='?page=wp-media-cleaner&s=<?php 
    echo $s;
    ?>
&view=deleted'><?php 
    _e("Trash", 'wp-media-cleaner');
    ?>
</a><span class="count">(<?php 
    echo $deleted_count;
    ?>
)</span></li>
		</ul>

		<table id='wpmc-table' class='wp-list-table widefat fixed media'>

			<thead>
				<tr>
					<th scope="col" id="cb" class="manage-column column-cb check-column"><input id="wpmc-cb-select-all" type="checkbox"></th>
					<th style='width: 64px;'>Thumb</th>
					<th style='width: 50px;'>Type</th>
					<th style='width: 80px;'>Origin</th>
					<th>Path</th>
					<th style='width: 220px;'>Issue</th>
					<th style='width: 80px; text-align: right;'>Size</th>
				</tr>
			</thead>

			<tbody>
				<?php 
    foreach ($items as $issue) {
        ?>
				<tr>
					<td><input type="checkbox" name="id" value="<?php 
        echo $issue->id;
        ?>
"></td>
					<td>
						<?php 
        if ($issue->deleted == 0) {
            if ($issue->type == 0) {
                // FILE
                $upload_dir = wp_upload_dir();
                echo "<img style='max-width: 48px; max-height: 48px;' src='" . htmlspecialchars($upload_dir['baseurl'] . '/' . $issue->path, ENT_QUOTES) . "' />";
            } else {
                // MEDIA
                $attachmentsrc = wp_get_attachment_image_src($issue->postId, 'thumbnail');
                echo "<img style='max-width: 48px; max-height: 48px;' src='" . htmlspecialchars($attachmentsrc[0], ENT_QUOTES) . "' />";
            }
        }
        ?>
					</td>
					<td><?php 
        echo $issue->type == 0 ? 'FILE' : 'MEDIA';
        ?>
</td>
					<td><?php 
        echo $issue->type == 0 ? 'Filesystem' : "<a href='media.php?attachment_id=" . $issue->postId . "&action=edit'>ID " . $issue->postId . "</a>";
        ?>
</td>
					<td><?php 
        echo stripslashes($issue->path);
        ?>
</td>
					<td><?php 
        echo_issue($issue->issue);
        ?>
</td>
					<td style='text-align: right;'><?php 
        echo number_format($issue->size / 1000, 2);
        ?>
 KB</td>
				</tr>
				<?php 
    }
    ?>
			</tbody>

			<tfoot>
				<tr><th></th><th></th><th>Type</th><th>Origin</th><th>Path</th><th>Issue</th><th style='width: 80px; text-align: right;'>Size</th></tr>
			</tfoot>

		</table>
	</wrap>

	<?php 
    jordy_meow_footer();
}
示例#6
0
 /**
  *
  * SETTINGS PAGE
  *
  */
 function settings_page()
 {
     global $mfrh_settings_api;
     echo '<div class="wrap">';
     jordy_meow_donation(true);
     echo "<div id='icon-options-general' class='icon32'><br></div><h1>Media File Renamer";
     by_jordy_meow();
     echo "</h1>";
     $mfrh_settings_api->show_navigation();
     $mfrh_settings_api->show_forms();
     echo '</div>';
     jordy_meow_footer();
 }
 /**
  *
  * SETTINGS PAGE
  *
  */
 function settings_page()
 {
     global $mfrh_settings_api;
     $hide_ads = $this->getoption('hide_ads', 'mfrh_basics', false);
     echo '<div class="wrap">';
     $hide_ads ? "" : jordy_meow_donation(true);
     echo "<div id='icon-options-general' class='icon32'><br></div><h1>Media File Renamer";
     by_jordy_meow($hide_ads);
     echo "</h1>";
     $mfrh_settings_api->show_navigation();
     $mfrh_settings_api->show_forms();
     echo '</div>';
     jordy_meow_footer();
 }