/** * Runs on activation */ function ajaxsearchpro_activate() { global $wpdb; require_once ABSPATH . 'wp-admin/includes/upgrade.php'; $charset_collate_bin_column = ''; $charset_collate = ''; if (!empty($wpdb->charset)) { $charset_collate_bin_column = "CHARACTER SET {$wpdb->charset}"; $charset_collate = "DEFAULT {$charset_collate_bin_column}"; } if (strpos($wpdb->collate, "_") > 0) { $charset_collate_bin_column .= " COLLATE " . substr($wpdb->collate, 0, strpos($wpdb->collate, '_')) . "_bin"; $charset_collate .= " COLLATE {$wpdb->collate}"; } else { if ($wpdb->collate == '' && $wpdb->charset == "utf8") { $charset_collate_bin_column .= " COLLATE utf8_bin"; } } if (isset($wpdb->base_prefix)) { $_prefix = $wpdb->base_prefix; } else { $_prefix = $wpdb->prefix; } $table_name = $_prefix . "ajaxsearchpro"; $query = "\r\n CREATE TABLE IF NOT EXISTS `{$table_name}` (\r\n `id` int(11) NOT NULL AUTO_INCREMENT,\r\n `name` text NOT NULL,\r\n `data` text NOT NULL,\r\n PRIMARY KEY (`id`)\r\n ) DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;\r\n "; dbDelta($query); $table_name = $_prefix . "ajaxsearchpro_statistics"; $query = "\r\n CREATE TABLE IF NOT EXISTS `{$table_name}` (\r\n `id` int(11) NOT NULL AUTO_INCREMENT,\r\n `search_id` int(11) NOT NULL,\r\n `keyword` text CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,\r\n `num` int(11) NOT NULL,\r\n `last_date` int(11) NOT NULL,\r\n PRIMARY KEY (`id`)\r\n ) DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;\r\n "; dbDelta($query); $query = "ALTER TABLE `{$table_name}` MODIFY `keyword` text CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL"; dbDelta($query); $wpdb->query($query); $table_name = $_prefix . "ajaxsearchpro_priorities"; $query = "\r\n CREATE TABLE IF NOT EXISTS `{$table_name}` (\r\n `post_id` int(11) NOT NULL,\r\n `blog_id` int(11) NOT NULL,\r\n `priority` int(11) NOT NULL,\r\n PRIMARY KEY (`post_id`, `blog_id`)\r\n ) DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;\r\n "; dbDelta($query); $query = "SHOW INDEX FROM `{$table_name}` WHERE KEY_NAME = 'post_blog_id'"; $index_exists = $wpdb->query($query); if ($index_exists == 0) { $query = "ALTER TABLE `{$table_name}` ADD INDEX `post_blog_id` (`post_id`, `blog_id`);"; $wpdb->query($query); } $this->create_index(); //@deprecated since 4.5 //$this->fulltext(); $this->chmod(); /** * If the asp_version option exists, then the plugin was used before. * In this case, re-creating the CSS files is highly advised. */ if (get_option('asp_version') !== false) { asp_generate_the_css(); } /** * Store the version number after everything is done. This is going to help distinguishing * stored asp_version from the ASP_CURR_VER variable. These two are different in cases: * - Uninstalling, installing new versions * - Uploading and overwriting old version with a new one */ update_option('asp_version', ASP_CURR_VER); }
function search_stylesheets() { global $wpdb; global $asp_head_out; if (function_exists('get_current_screen')) { $screen = get_current_screen(); if (isset($screen) && isset($screen->id) && $screen->id == 'widgets') { return; } } if (isset($wpdb->base_prefix)) { $_prefix = $wpdb->base_prefix; } else { $_prefix = $wpdb->prefix; } $search = $wpdb->get_results("SELECT * FROM " . $_prefix . "ajaxsearchpro", ARRAY_A); if (!is_array($search) || count($search) <= 0) { return; } $comp_settings = get_option('asp_compatibility'); $force_inline = w_isset_def($comp_settings['forceinlinestyles'], false); wp_enqueue_style('wpdreams_animations', plugins_url('css/animations.css', dirname(__FILE__)), array(), ASP_CURR_VER_STRING); wp_register_style('wpdreams-asp-basic', ASP_URL . 'css/style.basic.css', array(), ASP_CURR_VER_STRING); wp_enqueue_style('wpdreams-asp-basic'); if (ASP_DEBUG == 1) { asp_generate_the_css(); $css = get_option('asp_styles_base64'); $asp_head_out = base64_decode($css); add_action('wp_head', 'wpdreams_asp_echo_out', 10, 0); return; } else { if ($force_inline == 1) { $css = get_option('asp_styles_base64'); if ($css === false || $css == '') { asp_generate_the_css(); $css = get_option('asp_styles_base64'); // If it's still false, we have a problem if ($css === false || $css == '') { return; } } $asp_head_out = base64_decode($css); add_action('wp_head', 'wpdreams_asp_echo_out', 10, 0); return; } else { if (!file_exists(ASP_CSS_PATH . "/style.instances.css") || @filesize(ASP_CSS_PATH . "/style.instances.css") < 1025) { /* Check if the CSS exists, if not, then try to force-create it */ asp_generate_the_css(); // Check again, if doesn't exist, we need to force inline styles if (!file_exists(ASP_CSS_PATH . "/style.instances.css") || @filesize(ASP_CSS_PATH . "/style.instances.css") < 1025) { $css = get_option('asp_styles_base64'); // Still no CSS? Problem. if ($css === false || $css == '') { return; } $asp_head_out = base64_decode($css); add_action('wp_head', 'wpdreams_asp_echo_out', 10, 0); // Save the force inline $comp_settings['forceinlinestyles'] = 1; update_option('asp_compatibility', $comp_settings); return; } } } } wp_enqueue_style('wpdreams-ajaxsearchpro-instances', ASP_URL . 'css/style.instances.css', array(), ASP_CURR_VER_STRING); }
<?php include ASP_PATH . "backend/tabs/instance/advanced_options.php"; ?> </fieldset> </div> </div> <input type="hidden" name="sett_tabid" id="sett_tabid" value="1" /> </form> </div> <?php $output = ob_get_clean(); ?> <?php if (isset($_POST['submit_' . $search['id']])) { $params = wpdreams_parse_params($_POST); //print_r($params); $data = wd_mysql_escape_mimic(json_encode($params)); //print_r($_POST); $search['id'] = (int) $search['id']; // secure the parameter $wpdb->query("\n UPDATE " . $_prefix . "ajaxsearchpro\n SET data = '" . $data . "'\n WHERE id = " . $search['id'] . "\n "); $style = $params; $id = $search['id']; asp_register_wpml_translations($params); asp_generate_the_css(); echo "<div class='successMsg'>Search settings saved!</div>"; } echo $output; ?> </div>