예제 #1
0
function ewww_image_optimizer_preinit()
{
    global $ewww_debug;
    $ewww_debug .= '<b>ewww_image_optimizer_preinit()</b><br>';
    load_plugin_textdomain(EWWW_IMAGE_OPTIMIZER_DOMAIN, false, dirname(plugin_basename(__FILE__)) . '/languages/');
    $active_plugins = get_option('active_plugins');
    if (is_multisite()) {
        $active_plugins = array_merge($active_plugins, array_flip(get_site_option('active_sitewide_plugins')));
    }
    /*if ( strtoupper( substr( PHP_OS, 0, 3 ) ) == 'WIN' ) {
    		$ewww_plugins_path = str_replace( '/', '\\', EWWW_IMAGE_OPTIMIZER_PLUGIN_FILE_REL );
    	} else {
    		$ewww_plugins_path = EWWW_IMAGE_OPTIMIZER_PLUGIN_FILE_REL;
    	}
    	$ewww_plugins_path = str_replace( $ewww_plugins_path, '', EWWW_IMAGE_OPTIMIZER_PLUGIN_FILE );*/
    foreach ($active_plugins as $active_plugin) {
        if (strpos($active_plugin, 'nggallery.php')) {
            //$ngg = ewww_image_optimizer_get_plugin_version( $ewww_plugins_path . $active_plugin );
            $ngg = ewww_image_optimizer_get_plugin_version(trailingslashit(WP_PLUGIN_DIR) . $active_plugin);
            // include the file that loads the nextgen gallery optimization functions
            $ewww_debug .= 'Nextgen version: ' . $ngg['Version'] . '<br>';
            if (preg_match('/^2\\./', $ngg['Version'])) {
                // for Nextgen 2
                $ewww_debug .= "loading nextgen2 support<br>";
                require EWWW_IMAGE_OPTIMIZER_PLUGIN_PATH . 'nextgen2-integration.php';
            } else {
                preg_match('/\\d+\\.\\d+\\.(\\d+)/', $ngg['Version'], $nextgen_minor_version);
                if (!empty($nextgen_minor_version[1]) && $nextgen_minor_version[1] < 14) {
                    $ewww_debug .= "loading nextgen legacy support<br>";
                    require EWWW_IMAGE_OPTIMIZER_PLUGIN_PATH . 'nextgen-integration.php';
                } elseif (!empty($nextgen_minor_version[1]) && $nextgen_minor_version[1] > 13) {
                    $ewww_debug .= "loading nextcellent support<br>";
                    require EWWW_IMAGE_OPTIMIZER_PLUGIN_PATH . 'nextcellent-integration.php';
                }
            }
        }
        if (strpos($active_plugin, 'flag.php')) {
            $ewww_debug .= "loading flagallery support<br>";
            // include the file that loads the grand flagallery optimization functions
            require EWWW_IMAGE_OPTIMIZER_PLUGIN_PATH . 'flag-integration.php';
        }
    }
}
예제 #2
0
function ewww_image_optimizer_import_init()
{
    // verify that an authorized user has started the optimizer
    if (!wp_verify_nonce($_REQUEST['ewww_wpnonce'], 'ewww-image-optimizer-bulk')) {
        wp_die(__('Cheatin&#8217; eh?', EWWW_IMAGE_OPTIMIZER_DOMAIN));
    }
    global $ewww_debug;
    global $wpdb;
    $import_todo = 0;
    $import_status['media'] = 0;
    $import_todo += $wpdb->get_var("SELECT COUNT(posts.ID) FROM {$wpdb->postmeta} metas INNER JOIN {$wpdb->posts} posts ON posts.ID = metas.post_id WHERE posts.post_mime_type LIKE '%image%' AND metas.meta_key = '_wp_attachment_metadata' AND metas.meta_value LIKE '%ewww_image_optimizer%'");
    if (!function_exists('is_plugin_active')) {
        // need to include the plugin library for the is_plugin_active function
        require_once ABSPATH . 'wp-admin/includes/plugin.php';
    }
    if (is_plugin_active('nextgen-gallery/nggallery.php') || function_exists('is_plugin_active_for_network') && is_plugin_active_for_network('nextgen-gallery/nggallery.php')) {
        $nextgen_data = ewww_image_optimizer_get_plugin_version(trailingslashit(WP_PLUGIN_DIR) . 'nextgen-gallery/nggallery.php');
        //$nextgen_data = get_plugin_data( trailingslashit( WP_PLUGIN_DIR ) . 'nextgen-gallery/nggallery.php', false, false );
        $ewww_debug .= 'Nextgen version: ' . $nextgen_data['Version'] . '<br>';
        if (preg_match('/^2\\./', $nextgen_data['Version'])) {
            // for Nextgen 2
            $import_todo += $wpdb->get_var("SELECT COUNT(pid) FROM {$wpdb->nggpictures} WHERE meta_data LIKE '%ewww_image_optimizer%'");
            $import_status['nextgen'] = 0;
        }
    }
    if (is_plugin_active('flash-album-gallery/flag.php') || function_exists('is_plugin_active_for_network') && is_plugin_active_for_network('flash-album-gallery/flag.php')) {
        $import_todo += $wpdb->get_var("SELECT COUNT(pid) FROM {$wpdb->flagpictures} WHERE meta_data LIKE '%ewww_image_optimizer%'");
        $import_status['flag'] = 0;
    }
    update_option('ewww_image_optimizer_import_status', $import_status);
    $temp_column = $wpdb->get_var("SELECT * FROM information_schema.COLUMNS WHERE TABLE_NAME = '{$wpdb->ewwwio_images}' AND COLUMN_NAME = 'temp'");
    if (!$temp_column) {
        $wpdb->query("ALTER TABLE {$wpdb->ewwwio_images} ADD temp BOOLEAN NOT NULL");
    }
    echo $import_todo;
    die;
}
예제 #3
0
function ewww_image_optimizer_gallery_support()
{
    ewwwio_debug_message('<b>' . __FUNCTION__ . '()</b>');
    $active_plugins = get_option('active_plugins');
    if (is_multisite()) {
        $active_plugins = array_merge($active_plugins, array_flip(get_site_option('active_sitewide_plugins')));
    }
    foreach ($active_plugins as $active_plugin) {
        if (strpos($active_plugin, '/nggallery.php') || strpos($active_plugin, '\\nggallery.php')) {
            //$ngg = ewww_image_optimizer_get_plugin_version( $ewww_plugins_path . $active_plugin );
            $ngg = ewww_image_optimizer_get_plugin_version(trailingslashit(WP_PLUGIN_DIR) . $active_plugin);
            // include the file that loads the nextgen gallery optimization functions
            ewwwio_debug_message('Nextgen version: ' . $ngg['Version']);
            if (preg_match('/^2\\./', $ngg['Version'])) {
                // for Nextgen 2
                ewwwio_debug_message("loading nextgen2 support for {$active_plugin}");
                require_once EWWW_IMAGE_OPTIMIZER_PLUGIN_PATH . 'nextgen2-integration.php';
            } else {
                preg_match('/\\d+\\.\\d+\\.(\\d+)/', $ngg['Version'], $nextgen_minor_version);
                if (!empty($nextgen_minor_version[1]) && $nextgen_minor_version[1] < 14) {
                    ewwwio_debug_message("NOT loading nextgen legacy support for {$active_plugin}");
                } elseif (!empty($nextgen_minor_version[1]) && $nextgen_minor_version[1] > 13) {
                    ewwwio_debug_message("loading nextcellent support for {$active_plugin}");
                    require_once EWWW_IMAGE_OPTIMIZER_PLUGIN_PATH . 'nextcellent-integration.php';
                }
            }
        }
        if (strpos($active_plugin, '/flag.php') || strpos($active_plugin, '\\flag.php')) {
            ewwwio_debug_message("loading flagallery support for {$active_plugin}");
            // include the file that loads the grand flagallery optimization functions
            require_once EWWW_IMAGE_OPTIMIZER_PLUGIN_PATH . 'flag-integration.php';
        }
    }
}
예제 #4
0
function ewww_image_optimizer_gallery_support()
{
    ewwwio_debug_message('<b>' . __FUNCTION__ . '()</b>');
    $active_plugins = get_option('active_plugins');
    if (is_multisite()) {
        $active_plugins = array_merge($active_plugins, array_flip(get_site_option('active_sitewide_plugins')));
    }
    /*if ( strtoupper( substr( PHP_OS, 0, 3 ) ) == 'WIN' ) {
    		$ewww_plugins_path = str_replace( '/', '\\', EWWW_IMAGE_OPTIMIZER_PLUGIN_FILE_REL );
    	} else {
    		$ewww_plugins_path = EWWW_IMAGE_OPTIMIZER_PLUGIN_FILE_REL;
    	}
    	$ewww_plugins_path = str_replace( $ewww_plugins_path, '', EWWW_IMAGE_OPTIMIZER_PLUGIN_FILE );*/
    foreach ($active_plugins as $active_plugin) {
        if (strpos($active_plugin, 'nggallery.php')) {
            //$ngg = ewww_image_optimizer_get_plugin_version( $ewww_plugins_path . $active_plugin );
            $ngg = ewww_image_optimizer_get_plugin_version(trailingslashit(WP_PLUGIN_DIR) . $active_plugin);
            // include the file that loads the nextgen gallery optimization functions
            ewwwio_debug_message('Nextgen version: ' . $ngg['Version']);
            if (preg_match('/^2\\./', $ngg['Version'])) {
                // for Nextgen 2
                ewwwio_debug_message('loading nextgen2 support');
                require EWWW_IMAGE_OPTIMIZER_PLUGIN_PATH . 'nextgen2-integration.php';
            } else {
                preg_match('/\\d+\\.\\d+\\.(\\d+)/', $ngg['Version'], $nextgen_minor_version);
                if (!empty($nextgen_minor_version[1]) && $nextgen_minor_version[1] < 14) {
                    ewwwio_debug_message('loading nextgen legacy support');
                    require EWWW_IMAGE_OPTIMIZER_PLUGIN_PATH . 'nextgen-integration.php';
                } elseif (!empty($nextgen_minor_version[1]) && $nextgen_minor_version[1] > 13) {
                    ewwwio_debug_message('loading nextcellent support');
                    require EWWW_IMAGE_OPTIMIZER_PLUGIN_PATH . 'nextcellent-integration.php';
                }
            }
        }
        if (strpos($active_plugin, 'flag.php')) {
            ewwwio_debug_message('loading flagallery support');
            // include the file that loads the grand flagallery optimization functions
            require EWWW_IMAGE_OPTIMIZER_PLUGIN_PATH . 'flag-integration.php';
        }
    }
    //	ewww_image_optimizer_debug_log();
}