/** * From wp-admin/includes/image-edit.php */ function pte_image_get_preview_ratio($w, $h) { $options = pte_get_options(); $img_max_size = $options['pte_imgedit_max_size']; $max = max($w, $h); return $max > $img_max_size ? $img_max_size / $max : 1; }
function pte_get_jpeg_quality($quality) { $options = pte_get_options(); $jpeg_compression = $options['pte_jpeg_compression']; if (isset($_GET['pte-jpeg-compression'])) { $tmp_jpeg = intval($_GET['pte-jpeg-compression']); if (0 <= $tmp_jpeg && $tmp_jpeg <= 100) { $jpeg_compression = $tmp_jpeg; } } PteLogger::debug("COMPRESSION: " . $jpeg_compression); return $jpeg_compression; }
function pte_media_row_actions($actions, $post, $detached) { // Add capability check if (!pte_check_id($post->ID)) { return $actions; } $options = pte_get_options(); $pte_url = pte_url($post->ID); $actions['pte'] = "<a href='{$pte_url}' title='" . __('Edit Thumbnails', PTE_DOMAIN) . "'>" . __('Thumbnails', PTE_DOMAIN) . "</a>"; return $actions; }
function pte_sizes_display() { require_once 'functions.php'; $options = pte_get_options(); // Table Header ?> <table><tr><th><?php _e("Post Thumbnail", PTE_DOMAIN); ?> </th> <th><?php _e("Hidden", PTE_DOMAIN); ?> </th> </tr> <?php // End table header $sizes = pte_get_alternate_sizes(false); foreach ($sizes as $size => $size_data) { $hidden = in_array($size, $options['pte_hidden_sizes']) ? "checked" : ""; $name = isset($size_data['display_name']) ? $size_data['display_name'] : $size; print "<tr><td><label for='{$size}'>{$name}</label></td>" . "<td><input type='checkbox' id='{$size}' name='pte-site-options[pte_hidden_sizes][]'" . " value='{$size}' {$hidden}></td>" . "</tr>"; } print '</table>'; }
function pte_write_image($image, $orig_type, $destfilename) { $logger = PteLogger::singleton(); $dir = dirname($destfilename); if (!is_dir($dir)) { if (!mkdir($dir, 0777, true)) { $logger->warn("Error creating directory: {$dir}"); } } if (IMAGETYPE_GIF == $orig_type) { if (!imagegif($image, $destfilename)) { $logger->error("Resize path invalid"); return false; } } elseif (IMAGETYPE_PNG == $orig_type) { if (!imagepng($image, $destfilename)) { $logger->error("Resize path invalid"); return false; } } else { // all other formats are converted to jpg $options = pte_get_options(); $quality = apply_filters('jpeg_quality', $options['pte_jpeg_compression'], 'pte_write_image'); $logger->debug("JPEG COMPRESSION: {$quality}"); if (!imagejpeg($image, $destfilename, $quality)) { $logger->error("Resize path invalid: " . $destfilename); return false; } } imagedestroy($image); // Set correct file permissions $stat = stat(dirname($destfilename)); $perms = $stat['mode'] & 0666; //same permissions as parent folder, strip off the executable bits @chmod($destfilename, $perms); return true; }
</div> </div> </div> </div> </div> </div> </div> </div> <div id="pte-iris-dialog"> <input type="text" name="pteIris" id="pteIris" value="" /> </div> <?php function enqueue_script_filter($tag, $handle) { if ('pte-require' !== $handle) { return $tag; } return str_replace(' src', ' data-main="' . PTE_PLUGINURL . 'js/main" src', $tag); } function enqueue_last() { wp_enqueue_script('pte-require', PTE_PLUGINURL . "apps/requirejs/require.js", null, PTE_VERSION, true); } $options = pte_get_options(); if ($options['pte_debug']) { add_action('wp_print_footer_scripts', 'enqueue_last', 1, 0); add_action('admin_print_footer_scripts', 'enqueue_last', 1, 0); add_filter('script_loader_tag', 'enqueue_script_filter', 10, 2); } else { wp_enqueue_script('pte-min-js', PTE_PLUGINURL . "js-build/main.js", null, PTE_VERSION, true); }
private function pte_log($message, $type = NULL) { if (!$message instanceof PteLogMessage) { if (is_string($message)) { if (is_null($type)) { $type = $defaulttype; } try { $message = new PteLogMessage($type, $message); } catch (Exception $e) { printf(__("ERROR Logging Message: %s", PTE_DOMAIN), $message); } } else { return false; } } // If debug isn't enabled only track WARN and ERROR messages // (throw away DEBUG messages) $options = pte_get_options(); if (!$options['pte_debug'] and $type == PteLogMessage::$DEBUG) { return false; } $this->add_message($message); return true; }
function pte_media_row_actions($actions, $post, $detached) { // Add capability check if (!current_user_can('edit_post', $post->ID)) { return $actions; } $options = pte_get_options(); $thickbox = $options['pte_thickbox'] ? "class='thickbox'" : ""; $pte_url = admin_url('admin-ajax.php') . "?action=pte_ajax&pte-action=launch&id=" . $post->ID . "&TB_iframe=true&height={$options['pte_tb_height']}&width={$options['pte_tb_width']}"; $actions['pte'] = "<a {$thickbox} href='{$pte_url}' title='" . __('Edit Thumbnails', PTE_DOMAIN) . "'>" . __('Thumbnails', PTE_DOMAIN) . "</a>"; return $actions; }
function pte_jpeg_compression_display() { $options = pte_get_options(); $option_label = pte_get_option_name(); ?> <span><input class="small-text" type="text" name="pte-site-options[pte_jpeg_compression]" value="<?php print $options['pte_jpeg_compression']; ?> " id="pte_jpeg_compression"> <?php _e("Set the compression level for resizing jpeg images (0 to 100).", PTE_DOMAIN); ?> </span> <?php }