function ewww_ngg_image_save( $filename ) { ewwwio_debug_message( '<b>' . __FUNCTION__ . '()</b>' ); global $ewww_defer; if ( file_exists( $filename ) ) { global $ewwwio_image_background; $ewwwio_image_background->push_to_queue( $filename ); $ewwwio_image_background->save()->dispatch(); ewwwio_debug_message( "ngg thumb queued: $filename" ); } ewww_image_optimizer_debug_log(); ewwwio_memory( __FUNCTION__ ); }
function ewww_ngg_image_save($filename) { ewwwio_debug_message('<b>' . __FUNCTION__ . '()</b>'); global $ewww_defer; if (file_exists($filename)) { if ($ewww_defer && ewww_image_optimizer_get_option('ewww_image_optimizer_defer')) { ewww_image_optimizer_add_deferred_attachment("file,{$filename}"); return $saved; } ewww_image_optimizer($filename); ewwwio_debug_message("ngg_Thumbnail saved: {$filename}"); $image_size = ewww_image_optimizer_filesize($filename); ewwwio_debug_message("image editor size: {$image_size}"); } ewww_image_optimizer_debug_log(); ewwwio_memory(__FUNCTION__); }
function ewww_image_optimizer_filter_settings_page($input) { $output = ''; foreach ($input as $line) { if (EWWW_IMAGE_OPTIMIZER_CLOUD && preg_match("/class='nocloud'/", $line)) { continue; } else { $output .= $line; } } ewwwio_memory(__FUNCTION__); return $output; }
function generate_image_size($image, $size, $params = null, $skip_defaults = false) { ewwwio_debug_message('<b>' . __FUNCTION__ . '()</b>'); global $ewww_defer; if (!defined('EWWW_IMAGE_OPTIMIZER_CLOUD')) { ewww_image_optimizer_init(); } $success = $this->call_parent('generate_image_size', $image, $size, $params, $skip_defaults); if ($success) { $filename = $success->fileName; if ($ewww_defer && ewww_image_optimizer_get_option('ewww_image_optimizer_defer')) { ewww_image_optimizer_add_deferred_attachment("file,{$filename}"); return $saved; } ewww_image_optimizer($filename); ewwwio_debug_message("nextgen dynamic thumb saved: {$filename}"); $image_size = ewww_image_optimizer_filesize($filename); ewwwio_debug_message("optimized size: {$image_size}"); } ewww_image_optimizer_debug_log(); ewwwio_memory(__FUNCTION__); return $success; }
function ewww_image_optimizer_bulk_cleanup() { // verify that an authorized user has started the optimizer $permissions = apply_filters('ewww_image_optimizer_bulk_permissions', ''); if (!wp_verify_nonce($_REQUEST['ewww_wpnonce'], 'ewww-image-optimizer-bulk') || !current_user_can($permissions)) { wp_die(__('Cheatin’ eh?', EWWW_IMAGE_OPTIMIZER_DOMAIN)); } // all done, so we can update the bulk options with empty values update_option('ewww_image_optimizer_bulk_resume', ''); update_option('ewww_image_optimizer_bulk_attachments', ''); // and let the user know we are done echo '<p><b>' . __('Finished', EWWW_IMAGE_OPTIMIZER_DOMAIN) . '</b> - <a href="upload.php">' . __('Return to Media Library', EWWW_IMAGE_OPTIMIZER_DOMAIN) . '</a></p>'; ewwwio_memory(__FUNCTION__); die; }
function ewww_image_optimizer_install_pngout() { global $ewww_debug; $ewww_debug .= '<b>ewww_image_optimizer_install_pngout()</b><br>'; $permissions = apply_filters('ewww_image_optimizer_admin_permissions', ''); if (FALSE === current_user_can($permissions)) { wp_die(__('You don\'t have permission to install image optimizer utilities.', EWWW_IMAGE_OPTIMIZER_DOMAIN)); } if (PHP_OS != 'WINNT') { $tar = ewww_image_optimizer_find_binary('tar', 't'); } if (empty($tar) && PHP_OS != 'WINNT') { $pngout_error = __('tar command not found', EWWW_IMAGE_OPTIMIZER_DOMAIN); } if (PHP_OS == 'Linux') { $os_string = 'linux'; } if (PHP_OS == 'FreeBSD') { $os_string = 'bsd'; } $latest = '20150319'; if (empty($pngout_error)) { if (PHP_OS == 'Linux' || PHP_OS == 'FreeBSD') { $download_result = ewww_image_optimizer_escapeshellarg(download_url('http://static.jonof.id.au/dl/kenutils/pngout-' . $latest . '-' . $os_string . '-static.tar.gz')); if (is_wp_error($download_result)) { $pngout_error = $download_result->get_error_message(); } else { $arch_type = php_uname('m'); exec("{$tar} xzf {$download_result} -C " . ewww_image_optimizer_escapeshellarg(EWWW_IMAGE_OPTIMIZER_PLUGIN_PATH) . ' pngout-' . $latest . '-' . $os_string . '-static/' . $arch_type . '/pngout-static'); if (!rename(EWWW_IMAGE_OPTIMIZER_PLUGIN_PATH . 'pngout-' . $latest . '-' . $os_string . '-static/' . $arch_type . '/pngout-static', EWWW_IMAGE_OPTIMIZER_TOOL_PATH . 'pngout-static')) { if (empty($pngout_error)) { $pngout_error = __("could not move pngout", EWWW_IMAGE_OPTIMIZER_DOMAIN); } } if (!chmod(EWWW_IMAGE_OPTIMIZER_TOOL_PATH . 'pngout-static', 0755)) { if (empty($pngout_error)) { $pngout_error = __("could not set permissions", EWWW_IMAGE_OPTIMIZER_DOMAIN); } } $pngout_version = ewww_image_optimizer_tool_found(ewww_image_optimizer_escapeshellarg(EWWW_IMAGE_OPTIMIZER_TOOL_PATH) . 'pngout-static', 'p'); } } if (PHP_OS == 'Darwin') { $download_result = ewww_image_optimizer_escapeshellarg(download_url('http://static.jonof.id.au/dl/kenutils/pngout-' . $latest . '-darwin.tar.gz')); if (is_wp_error($download_result)) { $pngout_error = $download_result->get_error_message(); } else { exec("{$tar} xzf {$download_result} -C " . ewww_image_optimizer_escapeshellarg(EWWW_IMAGE_OPTIMIZER_PLUGIN_PATH) . ' pngout-' . $latest . '-darwin/pngout'); if (!rename(EWWW_IMAGE_OPTIMIZER_PLUGIN_PATH . 'pngout-' . $latest . '-darwin/pngout', EWWW_IMAGE_OPTIMIZER_TOOL_PATH . 'pngout-static')) { if (empty($pngout_error)) { $pngout_error = __("could not move pngout", EWWW_IMAGE_OPTIMIZER_DOMAIN); } } if (!chmod(EWWW_IMAGE_OPTIMIZER_TOOL_PATH . 'pngout-static', 0755)) { if (empty($pngout_error)) { $pngout_error = __("could not set permissions", EWWW_IMAGE_OPTIMIZER_DOMAIN); } } $pngout_version = ewww_image_optimizer_tool_found(ewww_image_optimizer_escapeshellarg(EWWW_IMAGE_OPTIMIZER_TOOL_PATH) . 'pngout-static', 'p'); } } } if (PHP_OS == 'WINNT') { $download_result = download_url('http://advsys.net/ken/util/pngout.exe'); if (is_wp_error($download_result)) { $pngout_error = $download_result->get_error_message(); } else { if (!rename($download_result, EWWW_IMAGE_OPTIMIZER_TOOL_PATH . 'pngout.exe')) { if (empty($pngout_error)) { $pngout_error = __("could not move pngout", EWWW_IMAGE_OPTIMIZER_DOMAIN); } } $pngout_version = ewww_image_optimizer_tool_found('"' . EWWW_IMAGE_OPTIMIZER_TOOL_PATH . 'pngout.exe"', 'p'); } } if (!empty($pngout_version)) { $sendback = add_query_arg('ewww_pngout', 'success', remove_query_arg(array('ewww_pngout', 'ewww_error'), wp_get_referer())); } if (!isset($sendback)) { $sendback = add_query_arg(array('ewww_pngout' => 'failed', 'ewww_error' => urlencode($pngout_error)), remove_query_arg(array('ewww_pngout', 'ewww_error'), wp_get_referer())); } wp_redirect(esc_url_raw($sendback)); ewwwio_memory(__FUNCTION__); exit(0); }
function generate_image_size($image, $size, $params = null, $skip_defaults = false) { global $ewww_debug; if (!defined('EWWW_IMAGE_OPTIMIZER_CLOUD')) { ewww_image_optimizer_init(); } $success = $this->call_parent('generate_image_size', $image, $size, $params, $skip_defaults); if ($success) { //$filename = $this->object->get_image_abspath($image, $size); $filename = $success->fileName; ewww_image_optimizer_aux_images_loop($filename, true); $ewww_debug .= "nextgen dynamic thumb saved: {$filename} <br>"; $image_size = filesize($filename); $ewww_debug .= "optimized size: {$image_size} <br>"; } ewww_image_optimizer_debug_log(); ewwwio_memory(__FUNCTION__); return $success; }
function ewww_image_optimizer_aux_images_cleanup($auto = false) { ewwwio_debug_message('<b>' . __FUNCTION__ . '()</b>'); // verify that an authorized user has started the optimizer $permissions = apply_filters('ewww_image_optimizer_bulk_permissions', ''); if (!$auto && (!wp_verify_nonce($_REQUEST['ewww_wpnonce'], 'ewww-image-optimizer-bulk') || !current_user_can($permissions))) { wp_die(esc_html__('Access denied.', EWWW_IMAGE_OPTIMIZER_DOMAIN)); } $stored_last = get_option('ewww_image_optimizer_aux_last'); update_option('ewww_image_optimizer_aux_last', array(time(), $stored_last[1])); // all done, so we can update the bulk options with empty values update_option('ewww_image_optimizer_aux_resume', ''); update_option('ewww_image_optimizer_aux_attachments', ''); if (!$auto) { // and let the user know we are done echo '<p><b>' . esc_html__('Finished', EWWW_IMAGE_OPTIMIZER_DOMAIN) . '</b></p>'; ewwwio_memory(__FUNCTION__); die; } }
function ewww_ngg_image_save($filename) { ewwwio_debug_message('<b>' . __FUNCTION__ . '()</b>'); global $ewww_defer; if (file_exists($filename)) { if (ewww_image_optimizer_get_option('ewww_image_optimizer_background_optimization')) { global $ewwwio_image_background; if (!class_exists('WP_Background_Process')) { require_once EWWW_IMAGE_OPTIMIZER_PLUGIN_PATH . 'background.php'; } if (!is_object($ewwwio_image_background)) { $ewwwio_image_background = new EWWWIO_Image_Background_Process(); } $ewwwio_image_background->push_to_queue($filename); $ewwwio_image_background->save()->dispatch(); ewwwio_debug_message("ngg thumb queued: {$filename}"); } else { ewww_image_optimizer($filename); } } ewww_image_optimizer_debug_log(); ewwwio_memory(__FUNCTION__); }
function ewww_image_optimizer_aux_images_cleanup($auto = false) { global $ewww_debug; $ewww_debug .= "<b>ewww_image_optimizer_aux_images_cleanup()</b><br>"; // verify that an authorized user has started the optimizer if (!$auto && (!wp_verify_nonce($_REQUEST['ewww_wpnonce'], 'ewww-image-optimizer-bulk') || !current_user_can('install_themes'))) { wp_die(__('Cheatin’ eh?', EWWW_IMAGE_OPTIMIZER_DOMAIN)); } $stored_last = get_option('ewww_image_optimizer_aux_last'); update_option('ewww_image_optimizer_aux_last', array(time(), $stored_last[1])); // all done, so we can update the bulk options with empty values update_option('ewww_image_optimizer_aux_resume', ''); update_option('ewww_image_optimizer_aux_attachments', ''); if (!$auto) { // and let the user know we are done echo '<p><b>' . __('Finished', EWWW_IMAGE_OPTIMIZER_DOMAIN) . '</b></p>'; ewwwio_memory(__FUNCTION__); die; } }