/** * @param int $slider_id * @param string $picture_folder_name * @param array $dimension_keys - possible keys width, height */ function packet_resize($slider_id, $picture_folder_name, $dimension_keys = array()) { global $wpdb; $file = new alfw_manage_files(); /** * Get slider options */ $slider_options = $wpdb->get_results($wpdb->prepare("SELECT\n id, deny_resize_img, width, height, thumb_width, thumb_height\n FROM\n `" . $wpdb->prefix . SLIDER_TABLE . "`\n WHERE\n id = %d\n ", $slider_id), ARRAY_A); $upload_dir_info = wp_upload_dir(); $uploads_folder_path = $upload_dir_info['basedir']; $path_to_resize_images = $uploads_folder_path . "/" . $picture_folder_name . "/" . $slider_id . "/"; $pictures = $file->enum_directory_files(FULL_UPLOAD_PATH_ORIG . "/" . $slider_id . "/"); foreach ($pictures as $picture) { /** * Check orientation */ $check_result = $file->check_orientation($slider_options[0][$dimension_keys['width']], $slider_options[0][$dimension_keys['height']], FULL_UPLOAD_PATH_ORIG . "/" . $slider_id . "/" . $picture); if ($slider_options[0]['deny_resize_img']) { /** * No resize image */ if ($check_result['check']) { if ($picture_folder_name == UPLOAD_FOLDER_NAME_THUMB) { $file->resize_upload_img(FULL_UPLOAD_PATH_ORIG . "/" . $slider_id . "/" . $picture, $picture, $slider_options[0][$dimension_keys['height']], $slider_options[0][$dimension_keys['width']], $path_to_resize_images, true, false); } else { $file->copy_file(FULL_UPLOAD_PATH_ORIG . "/" . $slider_id . "/" . $picture, $path_to_resize_images, $picture, false); } } else { /** * however needs correction (for diff orientation) */ $file->resize_upload_img(FULL_UPLOAD_PATH_ORIG . "/" . $slider_id . "/" . $picture, $picture, $check_result['resize_height'], $check_result['resize_width'], $path_to_resize_images, false, false); $file->center_place_img_to_canvas($slider_options[0][$dimension_keys['width']], $slider_options[0][$dimension_keys['height']], $check_result['frame_orient'], $path_to_resize_images . $picture); } } else { /** * Needs resize */ if ($check_result['check']) { $file->resize_upload_img(FULL_UPLOAD_PATH_ORIG . "/" . $slider_id . "/" . $picture, $picture, $slider_options[0][$dimension_keys['height']], $slider_options[0][$dimension_keys['width']], $path_to_resize_images, true, false); } else { $file->resize_upload_img(FULL_UPLOAD_PATH_ORIG . "/" . $slider_id . "/" . $picture, $picture, $check_result['resize_height'], $check_result['resize_width'], $path_to_resize_images, false, false); $file->center_place_img_to_canvas($slider_options[0][$dimension_keys['width']], $slider_options[0][$dimension_keys['height']], $check_result['frame_orient'], $path_to_resize_images . $picture); } } } }
* * Uninstalling Altima LookBook deletes sliders, slides, options and uploaded files. * * @author altimawebsystems.com * @version 1.0.6 */ if (!defined('WP_UNINSTALL_PLUGIN')) { exit; } define('ALTIMA_LOOKBOOK_PLUGIN_DIR', untrailingslashit(dirname(__FILE__))); require_once ALTIMA_LOOKBOOK_PLUGIN_DIR . '/includes/alfw_settings.php'; require_once ALTIMA_LOOKBOOK_PLUGIN_DIR . '/includes/alfwManage_files.class.php'; global $wpdb; /** * Cleen options */ foreach ($lookbook_settings_fields as $field_name => $val) { delete_option($field_name); } /** * Drop tables */ $wpdb->query("DROP TABLE `" . $wpdb->prefix . SLIDES_TABLE . "`"); $wpdb->query("DROP TABLE `" . $wpdb->prefix . SLIDER_TABLE . "`"); /** * Remove uploaded files */ $file = new alfw_manage_files(); $file->delete_directory(FULL_UPLOAD_PATH); $file->delete_directory(FULL_UPLOAD_PATH_THUMB); $file->delete_directory(FULL_UPLOAD_PATH_ORIG);
function lookbook_install() { global $wpdb; global $lookbook_settings_fields; $table_name = $wpdb->prefix . SLIDER_TABLE; if ($wpdb->get_var("show tables like '{$table_name}'") != $table_name) { $sql = "CREATE TABLE IF NOT EXISTS `" . $table_name . "` (\n `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n `name` varchar(255) NOT NULL,\n `width` smallint(5) unsigned NOT NULL,\n `height` smallint(5) unsigned NOT NULL,\n `slider_effect` text,\n `show_navigation` tinyint(1) unsigned NOT NULL,\n `navigation_on_hover_state_only` tinyint(1) unsigned NOT NULL,\n `show_thumbnails` tinyint(1) unsigned NOT NULL,\n `deny_resize_img` tinyint(1) unsigned NOT NULL,\n `pause` smallint(5) unsigned NOT NULL,\n `transition_duration` smallint(5) unsigned NOT NULL,\n `content_before` longtext NOT NULL,\n `content_after` longtext NOT NULL,\n `status` tinyint(1) unsigned NOT NULL,\n `show_slide_caption` tinyint(1) NOT NULL,\n `updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\n `created` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',\n `thumb_width` smallint(5) unsigned NOT NULL,\n `thumb_height` smallint(5) unsigned NOT NULL,\n PRIMARY KEY (`id`)\n ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1"; dbDelta($sql); $wpdb->query('INSERT INTO `' . $table_name . '` (`id`, `name`, `width`, `height`, `slider_effect`, `show_navigation`, `navigation_on_hover_state_only`, `show_thumbnails`, `deny_resize_img`, `pause`, `transition_duration`, `content_before`, `content_after`, `status`, `show_slide_caption`, `updated`, `created`, `thumb_width`, `thumb_height`) VALUES (1, \'Slide 1\', 1024, 500, \'a:1:{i:0;s:4:"fade";}\', 0, 0, 1, 0, 4000, 1500, \'\', \'\', 1, 0, \'0000-00-00 00:00:00\', \'0000-00-00 00:00:00\', 150, 100);'); } $table_name = $wpdb->prefix . SLIDES_TABLE; if ($wpdb->get_var("show tables like '{$table_name}'") != $table_name) { $sql = "CREATE TABLE IF NOT EXISTS `" . $table_name . "` (\n `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n `slider_id` int(10) unsigned NOT NULL,\n `name` varchar(255) NOT NULL,\n `caption` text NOT NULL,\n `order_flag` tinyint(127) unsigned NOT NULL,\n `link` varchar(255) NOT NULL,\n `status` tinyint(1) unsigned NOT NULL DEFAULT '0',\n `picture` varchar(255) NOT NULL,\n `hotsposts` text NOT NULL,\n `order` tinyint(3) unsigned NOT NULL,\n `updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\n `created` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',\n PRIMARY KEY (`id`)\n ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1"; dbDelta($sql); } /** * Store defaults options */ foreach ($lookbook_settings_fields as $key => $val) { $result = $wpdb->get_results("SELECT\n option_id\n FROM\n `" . $wpdb->prefix . "options" . "`\n WHERE\n option_name = '{$key}'", ARRAY_A); if (empty($result)) { $wpdb->insert($wpdb->prefix . 'options', array('option_name' => $key, 'option_value' => $val), array('%s', '%s')); } } /** * Create default folder for picture */ $file = new alfw_manage_files(); $file->create_folder_recursive(FULL_UPLOAD_PATH); $file->create_folder_recursive(FULL_UPLOAD_PATH_THUMB); $file->create_folder_recursive(FULL_UPLOAD_PATH_ORIG); }