/** * Export package configuration * * @return string */ public function export() { global $wp_version; // Get options $options = wp_load_alloptions(); // Get Site URL $site_url = site_url(); if (isset($options['siteurl'])) { $site_url = rtrim($options['siteurl'], '/'); } // Get Home URL $home_url = home_url(); if (isset($options['home'])) { $home_url = rtrim($options['home'], '/'); } // Default configuration $config = array('SiteURL' => $site_url, 'HomeURL' => $home_url, 'Plugin' => array('Version' => AI1WM_VERSION), 'WordPress' => array('Version' => $wp_version, 'Content' => WP_CONTENT_DIR)); // Get user identity if (apply_filters('ai1wm_keep_user_identity_on_export', false)) { $config['Export']['User'] = array('Id' => get_current_user_id()); } // Save package file $package = file_put_contents($this->storage()->package(), json_encode($config)); if (false === $package) { throw new Ai1wm_Import_Exception('Unable to write package.json file'); } }
/** * Custom implementation for get_context method. */ public function get_context() { global $content_width; if (class_exists('Easy_Digital_Downloads')) { global $edd_options; } $context = Timber::get_context(); $sidebar_primary = Timber::get_widgets('sidebar_primary'); $sidebar_footer = Timber::get_widgets('sidebar_footer'); $context['theme_mods'] = get_theme_mods(); $context['site_options'] = wp_load_alloptions(); $context['teaser_mode'] = apply_filters('maera/teaser/mode', 'excerpt'); $context['thumbnail']['width'] = apply_filters('maera/image/width', 600); $context['thumbnail']['height'] = apply_filters('maera/image/height', 371); $context['menu']['primary'] = has_nav_menu('primary_navigation') ? new TimberMenu('primary_navigation') : null; $context['sidebar']['primary'] = apply_filters('maera/sidebar/primary', $sidebar_primary); $context['sidebar']['footer'] = apply_filters('maera/sidebar/footer', $sidebar_footer); $context['pagination'] = Timber::get_pagination(); $context['comment_form'] = TimberHelper::get_comment_form(); $context['comments_args'] = array('style' => 'ul', 'reply_text' => __('Reply', 'maera'), 'short_ping' => true, 'avatar_size' => 60); $context['site_logo'] = get_option('site_logo', false); $context['content_width'] = $content_width; $context['sidebar_template'] = maera_templates_sidebar(); if (class_exists('Easy_Digital_Downloads')) { $data['edd_options'] = $edd_options; $data['download_categories'] = Timber::get_terms('download_category'); $data['download_tags'] = Timber::get_terms('download_tag'); $data['default_image'] = new TimberImage(get_template_directory_uri() . '/assets/images/default.png'); } return apply_filters('maera/timber/context', $context); }
function add_to_context($context) { $context['foo'] = 'bar'; $context['stuff'] = 'I am a value set in your functions.php file'; $context['notes'] = 'These values are available everytime you call Timber::get_context();'; $context['menu'] = new TimberMenu(); //$context['custom_wp_nav_menu'] = wp_nav_menu( array( 'container_class' => 'menu-header', 'echo' => false, 'menu_class' => 'nav-menu' ) ); $context['custom_wp_nav_menu'] = wp_nav_menu(array('container_class' => 'menu-header', 'echo' => false, 'menu_class' => 'nav-menu')); $context['site'] = $this; $context['theme_url'] = get_stylesheet_directory_uri(); $context['is_logged_in'] = is_user_logged_in(); $context['theme_mod'] = get_theme_mods(); $context['options'] = wp_load_alloptions(); $context['site_url'] = site_url(); if (is_home() || is_front_page()) { $context['is_home'] = true; } /* * Footer */ $context['footer_tag_line'] = get_option('footer_text'); $context['footer_address'] = get_option('address'); $context['footer_site_url'] = site_url(); $context['footer_inquiry_mail'] = get_option('inquiry_mail'); $context['footer_telephone'] = get_option('telephone'); $context['s_facebook'] = get_option('facebook'); $context['s_twitter'] = get_option('twitter'); $context['s_linkedin'] = get_option('linkedin'); $context['footer_copyright'] = get_option('copyright'); return $context; }
function blogolife_settings_page() { ?> <div class='wrap'> <h1><?php _e('BlogoLife old settings', 'blogolife'); ?> </h1> <?php $all_options = wp_load_alloptions(); $old_settings = array('wpl_logo_url', 'wpl_header_desc', 'wpl_ga_code', 'wpl_css', 'wpl_menu', 'wpl_next_preview_post', 'wpl_rss', 'wpl_favicon_url', 'wpl_display_categories_post', 'wpl_display_author_post', 'wpl_display_date_post', 'wpl_display_author_page', 'wpl_display_date_page', 'wpl_nivo', 'wpl_share_buttons_page', 'wpl_share_buttons_post', 'wpl_twitter', 'wpl_google_plus', 'wpl_facebook', 'wpl_linkedin', 'wpl_tumblr', 'wpl_delicious', 'wpl_digg', 'wpl_stumbleupon', 'wpl_flickr', 'wpl_picasa', 'wpl_youtube', 'wpl_dribbble', 'wpl_pinterest', 'wpl_meta_description', 'wpl_meta_keywords'); $my_options = array(); foreach ($all_options as $name => $value) { if (stristr($name, 'wpl_') && $value != '') { if (in_array($name, $old_settings)) { if ($name === 'wpl_ga_code') { $ua_regex = "/UA-[0-9]{5,}-[0-9]{1,}/"; preg_match_all($ua_regex, $value, $ua_id); $my_options[$name] = $ua_id[0][0]; } else { $my_options[$name] = $value; } } } } echo "<pre>"; print_r($my_options); echo "</pre>"; ?> </div> <?php }
function bapi_wp_site_options() { global $bapi_all_options; $bapi_all_options = wp_load_alloptions(); if (!isset($bapi_all_options['bapi_solutiondata'])) { $bapi_all_options['bapi_solutiondata'] = ''; } if (!isset($bapi_all_options['bapi_solutiondata_lastmod'])) { $bapi_all_options['bapi_solutiondata_lastmod'] = 0; } if (!isset($bapi_all_options['bapi_keywords_array'])) { $bapi_all_options['bapi_keywords_array'] = ''; } if (!isset($bapi_all_options['bapi_keywords_lastmod'])) { $bapi_all_options['bapi_keywords_lastmod'] = 0; } if (!isset($bapi_all_options['bapi_language'])) { $bapi_all_options['bapi_language'] = 'en-US'; } if (!isset($bapi_all_options['bapi_baseurl'])) { $bapi_all_options['bapi_baseurl'] = 'connect.bookt.com'; } if (defined('BAPI_BASEURL')) { $bapi_all_options['bapi_baseurl'] = BAPI_BASEURL; } if (!isset($bapi_all_options['bapi_first_look'])) { $bapi_all_options['bapi_first_look'] = 0; } //print_r($bapi_all_options); exit(); }
/** * Set site options. * @return $this */ public function get_options() { switch_to_blog($this->_my_site->blog_id); $this->_my_data["options"] = wp_load_alloptions(); restore_current_blog(); return $this; }
function remove_um() { global $ultimatemember; foreach (wp_load_alloptions() as $k => $v) { if (substr($k, 0, 3) == 'um_') { if ($k == 'um_core_pages') { $v = unserialize($v); foreach ($v as $post_id) { wp_delete_post($post_id, 1); } } delete_option($k); } } $forms = get_posts(array('post_type' => 'um_form', 'numberposts' => -1)); foreach ($forms as $form) { wp_delete_post($form->ID, 1); } $directories = get_posts(array('post_type' => 'um_directory', 'numberposts' => -1)); foreach ($directories as $directory) { wp_delete_post($directory->ID, 1); } $roles = get_posts(array('post_type' => 'um_role', 'numberposts' => -1)); foreach ($roles as $role) { wp_delete_post($role->ID, 1); } if (is_plugin_active(um_plugin)) { deactivate_plugins(um_plugin); } exit(wp_redirect(admin_url('plugins.php'))); }
function aa_app_options() { ob_start(); echo "<pre>"; print_r(wp_load_alloptions()); echo "</pre>"; return ob_get_clean(); }
/** * Changes the state of a certain patch in the database * * @since 3.3.0 */ function zh_cn_l10n_save_patch_states($patch_id, $updated_state, $flush = false) { $_zh_cn_l10n_preference_patches = unserialize(get_option('zh_cn_l10n_preference_patches')); $_zh_cn_l10n_preference_patches[$patch_id] = $updated_state; update_option('zh_cn_l10n_preference_patches', serialize($_zh_cn_l10n_preference_patches)); if ($flush) { wp_load_alloptions(); } }
function eme_options_delete() { $all_options = wp_load_alloptions(); foreach ($all_options as $name => $value) { if (preg_match('/^eme_/', $name)) { delete_option($name); } } }
/** * @ticket 22846 */ public function test_set_site_transient_is_not_stored_as_autoload_option() { $key = 'not_autoloaded'; if (is_multisite()) { $this->markTestSkipped('Does not apply when used in multisite.'); } set_site_transient($key, 'Not an autoload option'); $options = wp_load_alloptions(); $this->assertFalse(isset($options['_site_transient_' . $key])); }
/** * @ticket 22846 */ public function test_update_network_option_is_not_stored_as_autoload_option() { $key = rand_str(); if (is_multisite()) { $this->markTestSkipped('Does not apply when used in multisite.'); } update_network_option(null, $key, 'Not an autoload option'); $options = wp_load_alloptions(); $this->assertFalse(isset($options[$key])); }
function theme_admin_print_scripts() { wp_enqueue_script('jquery'); wp_enqueue_script('jquery-bqq'); wp_enqueue_script('jquery-ui-core'); wp_enqueue_script('jquery-ui-tabs'); wp_enqueue_script('theme-admin'); wp_enqueue_script('media-upload'); wp_enqueue_script('thickbox'); wp_enqueue_style('thickbox'); wp_enqueue_style("google-font-open-sans", "http://fonts.googleapis.com/css?family=Open+Sans:400,600"); $sidebars = array("default" => array(array("name" => "header", "label" => __("header", 'medicenter')), array("name" => "footer_top", "label" => __("footer top", 'medicenter')), array("name" => "footer_bottom", "label" => __("footer bottom", 'medicenter'))), "template-blog.php" => array(array("name" => "header", "label" => __("header", 'medicenter')), array("name" => "footer_top", "label" => __("footer top", 'medicenter')), array("name" => "footer_bottom", "label" => __("footer bottom", 'medicenter'))), "single.php" => array(array("name" => "header", "label" => __("header", 'medicenter')), array("name" => "footer_top", "label" => __("footer top", 'medicenter')), array("name" => "footer_bottom", "label" => __("footer bottom", 'medicenter'))), "single-features.php" => array(array("name" => "header", "label" => __("header", 'medicenter')), array("name" => "footer_top", "label" => __("footer top", 'medicenter')), array("name" => "footer_bottom", "label" => __("footer bottom", 'medicenter'))), "search.php" => array(array("name" => "header", "label" => __("header", 'medicenter')), array("name" => "footer_top", "label" => __("footer top", 'medicenter')), array("name" => "footer_bottom", "label" => __("footer bottom", 'medicenter'))), "template-default-without-breadcrumbs.php" => array(array("name" => "footer_top", "label" => __("footer top", 'medicenter')), array("name" => "footer_bottom", "label" => __("footer bottom", 'medicenter'))), "template-home.php" => array(array("name" => "top", "label" => __("top", 'medicenter')), array("name" => "footer_top", "label" => __("footer top", 'medicenter')), array("name" => "footer_bottom", "label" => __("footer bottom", 'medicenter'))), "404.php" => array(array("name" => "header", "label" => __("header", 'medicenter')), array("name" => "footer_top", "label" => __("footer top", 'medicenter')), array("name" => "footer_bottom", "label" => __("footer bottom", 'medicenter')))); //get theme sidebars $theme_sidebars = array(); $theme_sidebars_array = get_posts(array('post_type' => 'medicenter_sidebars', 'posts_per_page' => '-1', 'post_status' => 'publish', 'orderby' => 'menu_order', 'order' => 'ASC')); for ($i = 0; $i < count($theme_sidebars_array); $i++) { $theme_sidebars[$i]["id"] = $theme_sidebars_array[$i]->ID; $theme_sidebars[$i]["title"] = $theme_sidebars_array[$i]->post_title; } //get theme sliders $sliderAllShortcodeIds = array(); $allOptions = wp_load_alloptions(); foreach ($allOptions as $key => $value) { if (substr($key, 0, 26) == "medicenter_slider_settings") { $sliderAllShortcodeIds[] = $key; } } //get revolution sliders if (is_plugin_active('revslider/revslider.php')) { global $wpdb; $rs = $wpdb->get_results("\r\n\t\tSELECT id, title, alias\r\n\t\tFROM " . $wpdb->prefix . "revslider_sliders\r\n\t\tORDER BY id ASC LIMIT 100\r\n\t\t"); if ($rs) { foreach ($rs as $slider) { $sliderAllShortcodeIds[] = "revolution_slider_settings_" . $slider->alias; } } } //get layer sliders if (is_plugin_active('LayerSlider/layerslider.php')) { global $wpdb; $ls = $wpdb->get_results("\r\n\t\tSELECT id, name, date_c\r\n\t\tFROM " . $wpdb->prefix . "layerslider\r\n\t\tWHERE flag_hidden = '0' AND flag_deleted = '0'\r\n\t\tORDER BY date_c ASC LIMIT 999\r\n\t\t"); $layer_sliders = array(); if ($ls) { foreach ($ls as $slider) { $sliderAllShortcodeIds[] = "aaaaalayer_slider_settings_" . $slider->id; } } } //sort slider ids sort($sliderAllShortcodeIds); $data = array('img_url' => get_template_directory_uri() . "/images/", 'admin_img_url' => get_template_directory_uri() . "/admin/images/", 'sidebar_label' => __('Sidebar', 'medicenter'), 'slider_label' => __('Main Slider', 'medicenter'), 'sidebars' => $sidebars, 'theme_sidebars' => $theme_sidebars, 'page_sidebars' => get_post_meta(get_the_ID(), "medicenter_page_sidebars", true), 'theme_sliders' => $sliderAllShortcodeIds, 'main_slider' => get_post_meta(get_the_ID(), "main_slider", true)); //pass data to javascript $params = array('l10n_print_after' => 'config = ' . json_encode($data) . ';'); wp_localize_script("theme-admin", "config", $params); }
/** * Fix a race condition in alloptions caching * * See https://core.trac.wordpress.org/ticket/31245 */ function _wpcom_vip_maybe_clear_alloptions_cache($option) { if (!wp_installing()) { $alloptions = wp_load_alloptions(); //alloptions should be cached at this point if (isset($alloptions[$option])) { //only if option is among alloptions wp_cache_delete('alloptions', 'options'); } } }
/** * Returns all options * * @param string $prefix * @return array */ public function all($prefix) { $options = wp_load_alloptions(); $pluginOptions = array(); foreach ($options as $key => $value) { if (substr($key, 0, $length = strlen($prefix)) === $prefix) { $pluginOptions[substr($key, $length)] = $value; } } return $pluginOptions; }
function display($file) { global $wp_styles; wp_load_alloptions(); do_action('after_setup_theme'); $_SESSION['wp_init'] = false; do_action('init'); try { include APPL_PATH . $this->templates . DIR_SEP . $file; } catch (Exception $e) { } }
function icl_st_scan_options_strings() { $options = wp_load_alloptions(); foreach ($options as $name => $value) { if ($this->is_blacklisted($name)) { unset($options[$name]); } else { $options[$name] = maybe_unserialize($value); } } return $options; }
/** * 自动处理保存在数据库中的 Portal,自动发表新文章,用于计划任务 * * @version 0.13.10.17 */ function add() { $option = wp_load_alloptions(); foreach ($option as $key => $value) { if (0 === strpos($key, 'idea_ingress_portal_')) { $this->portal = array_merge($this->portal, unserialize($value)); delete_option($key); } } // var_dump ( $this->portal ); $this->insert_portal(); }
public static function remove_preview_options() { if (!HeadwayCapabilities::can_user_visually_edit()) { return; } //Fetch all options in wp_options and remove the preview-specific options foreach (wp_load_alloptions() as $option => $option_value) { //This if statement is incredibly important and must not be tampered with and needs to be triple-checked if changed. if (preg_match('/^headway_(.*)?_preview$/', $option) && strpos($option, 'headway_') === 0 && strpos($option, '_preview') !== false) { delete_option($option); } } }
function rs_wpss_uninstall_plugin() { /* Delete Options */ $del_options = array('wp_spamshield_version', 'spamshield_options', 'spamshield_widget_settings', 'spamshield_last_admin', 'spamshield_admins', 'spamshield_admin_notices', 'spamshield_count', 'spamshield_reg_count', 'spamshield_procdat', 'spamshield_install_status', 'spamshield_warning_status', 'spamshield_regalert_status', 'spamshield_nonces', 'spamshield_wpssmid_cache', 'spamshield_ubl_cache', 'spamshield_ubl_cache_disable', 'spamshield_ip_ban_disable', 'spamshield_ip_ban', 'spamshield_whitelist_keys', 'ak_count_pre', 'spamshield_init_user_approve_run'); foreach ($del_options as $i => $option) { delete_option($option); } /* TO DO: When Network Activation enabled, add Multisite - delete_site_option() */ /* Delete Transients */ $del_trans = array('wpss_iswpv_check'); foreach ($del_trans as $i => $transient) { delete_transient($transient); delete_site_transient($transient); } /* Unregister Widgets */ $unreg_widgets = array('WP_SpamShield_Counter_LG', 'WP_SpamShield_Counter_CG', 'WP_SpamShield_End_Blog_Spam'); foreach ($unreg_widgets as $i => $widget) { unregister_widget($widget); } /* Clean Up Widget Options */ $all_widgets = get_option('sidebars_widgets'); foreach ($all_widgets as $i => $s) { if (is_array($s)) { foreach ($s as $k => $v) { if (FALSE !== strpos($v, 'spamshield')) { unset($all_widgets[$i][$k]); } } $all_widgets[$i] = array_values($all_widgets[$i]); } } update_option('sidebars_widgets', $all_widgets); /* Delete Orphaned Options */ $all_options = wp_load_alloptions(); foreach ($all_options as $option => $value) { if (FALSE !== strpos($option, 'spamshield')) { delete_option($option); } /* TO DO: When Network Activation enabled, add Multisite - delete_site_option() */ } /* Delete User Meta */ $del_user_meta = array('wpss_user_ip', 'wpss_admin_status', 'wpss_new_user_approved', 'wpss_new_user_email_sent', 'wpss_cpn_status', 'wpss_cpn_notices', 'wpss_nag_status', 'wpss_nag_notices'); $user_ids = get_users(array('blog_id' => '', 'fields' => 'ID')); foreach ($user_ids as $user_id) { foreach ($del_user_meta as $i => $key) { delete_user_meta($user_id, $key); } } /* Clear Banned IP Info */ rs_wpss_uninstall_ip_ban_htaccess(); }
public static function execute( $params ) { global $wp_version; // Set progress Ai1wm_Status::info( __( 'Adding configuration to archive...', AI1WM_PLUGIN_NAME ) ); // Initialize empty WP cache wp_cache_init(); // Get options $options = wp_load_alloptions(); // Set config $config = new Ai1wm_Config; // Set Site URL if ( isset( $options['siteurl'] ) ) { $config->SiteURL = untrailingslashit( $options['siteurl'] ); } else { $config->SiteURL = site_url(); } // Set Home URL if ( isset( $options['home'] ) ) { $config->HomeURL = untrailingslashit( $options['home'] ); } else { $config->HomeURL = home_url(); } // Set Plugin Version $config->Plugin = (object) array( 'Version' => AI1WM_VERSION ); // Set WordPress Version and Content $config->WordPress = (object) array( 'Version' => $wp_version, 'Content' => WP_CONTENT_DIR ); // Save package.json file $handle = fopen( ai1wm_package_path( $params ), 'w' ); fwrite( $handle, json_encode( $config ) ); fclose( $handle ); // Add package.json file $archive = new Ai1wm_Compressor( ai1wm_archive_path( $params ) ); $archive->add_file( ai1wm_package_path( $params ), AI1WM_PACKAGE_NAME ); $archive->close(); // Set progress Ai1wm_Status::info( __( 'Done adding configuration to archive.', AI1WM_PLUGIN_NAME ) ); return $params; }
function updateOptions() { $args = array('posts_per_page' => 1, 'post_type' => 'shop_options'); $opt_post = get_posts($args); $opt_to_rewrite = array('jigoshop_default_country', 'jigoshop_currency', 'jigoshop_catalog_product_button', 'jigoshop_catalog_sort_direction', 'jigoshop_catalog_columns', 'jigoshop_catalog_per_page', 'jigoshop_use_wordpress_tiny_crop', 'jigoshop_use_wordpress_thumbnail_crop', 'jigoshop_use_wordpress_catalog_crop', 'jigoshop_use_wordpress_featured_crop', 'jigoshop_shop_tiny_w', 'jigoshop_shop_tiny_h', 'jigoshop_shop_thumbnail_w', 'jigoshop_shop_thumbnail_h', 'jigoshop_shop_small_w', 'jigoshop_shop_small_h', 'jigoshop_shop_large_w', 'jigoshop_shop_large_h', 'jigoshop_shop_page_id', 'jigoshop_shop_redirect_page_id', 'jigoshop_cart_page_id', 'jigoshop_track_order_page_id', 'jigoshop_myaccount_page_id', 'jigoshop_edit_address_page_id', 'jigoshop_change_password_page_id', 'jigoshop_view_order_page_id', 'jigoshop_checkout_page_id', 'jigoshop_pay_page_id', 'jigoshop_thanks_page_id'); if ($opt_post) { $all_options = wp_load_alloptions(); foreach ($opt_post as $post) { foreach ($all_options as $name => $value) { if (in_array($name, $opt_to_rewrite)) { update_post_meta($post->ID, $name, $value); } } } } }
function _wp_specialchars($string, $quote_style = ENT_NOQUOTES, $charset = false, $double_encode = false) { $string = (string) $string; if (0 === strlen($string)) { return ''; } // Don't bother if there are no specialchars - saves some processing if (!preg_match('/[&<>"\']/', $string)) { return $string; } // Account for the previous behaviour of the function when the $quote_style is not an accepted value if (empty($quote_style)) { $quote_style = ENT_NOQUOTES; } elseif (!in_array($quote_style, array(0, 2, 3, 'single', 'double'), true)) { $quote_style = ENT_QUOTES; } // Store the site charset as a static to avoid multiple calls to wp_load_alloptions() if (!$charset) { static $_charset = null; if (!isset($_charset)) { $alloptions = wp_load_alloptions(); $_charset = isset($alloptions['blog_charset']) ? $alloptions['blog_charset'] : ''; } $charset = $_charset; } if (in_array($charset, array('utf8', 'utf-8', 'UTF8'))) { $charset = 'UTF-8'; } $_quote_style = $quote_style; if ($quote_style === 'double') { $quote_style = ENT_COMPAT; $_quote_style = ENT_COMPAT; } elseif ($quote_style === 'single') { $quote_style = ENT_NOQUOTES; } if (!$double_encode) { // Guarantee every &entity; is valid, convert &garbage; into &garbage; // This is required for PHP < 5.4.0 because ENT_HTML401 flag is unavailable. $string = wp_kses_normalize_entities($string); } $string = @htmlspecialchars($string, $quote_style, $charset, $double_encode); // Backwards compatibility if ('single' === $_quote_style) { $string = str_replace("'", ''', $string); } return $string; }
public function compareToDefault() { $ret = array(); $currentOptions = wp_load_alloptions(); $defaultOptions = $this->getDefaults($wp_version); foreach ($currentOptions as $name => $option) { if (substr($name, 0, 1) == '_') { continue; } if (!isset($defaultOptions[$name])) { $obj = new stdClass(); $obj->name = $name; $obj->state = self::STATE_NEW; $obj->default = null; $obj->current = $option; $ret[$name] = $obj; } else { // this option existied at the start. if ($option == $defaultOptions[$name]) { // unchanged $obj = new stdClass(); $obj->name = $name; $obj->state = self::STATE_UNCHANGED; $obj->default = $option; $obj->current = $option; $ret[$name] = $obj; } else { $obj = new stdClass(); $obj->name = $name; $obj->state = self::STATE_MODIFIED; $obj->default = $defaultOptions[$name]; $obj->current = $option; $ret[$name] = $obj; } } } foreach ($ret as $name => &$obj) { $obj->meta = $this->standardOption; foreach ($this->optionMeta as $metaName => $meta) { $match = preg_match('/' . $metaName . '/', $name); if ($match) { $obj->meta = $meta; } } } return $ret; }
public static function execute($params) { global $wp_version; // Set progress Ai1wm_Status::info(__('Adding configuration to archive...', AI1WM_PLUGIN_NAME)); // Flush WP cache ai1wm_cache_flush(); // Get options $options = wp_load_alloptions(); // Set config $config = array(); // Set Site URL if (isset($options['siteurl'])) { $config['SiteURL'] = untrailingslashit($options['siteurl']); } else { $config['SiteURL'] = site_url(); } // Set Home URL if (isset($options['home'])) { $config['HomeURL'] = untrailingslashit($options['home']); } else { $config['HomeURL'] = home_url(); } // Set Plugin Version $config['Plugin'] = array('Version' => AI1WM_VERSION); // Set WordPress Version and Content $config['WordPress'] = array('Version' => $wp_version, 'Content' => WP_CONTENT_DIR); // Set No Replace Email if (isset($params['options']['no_email_replace'])) { $config['NoEmailReplace'] = true; } // Save package.json file $handle = fopen(ai1wm_package_path($params), 'w'); fwrite($handle, json_encode($config)); fclose($handle); // Add package.json file $archive = new Ai1wm_Compressor(ai1wm_archive_path($params)); $archive->add_file(ai1wm_package_path($params), AI1WM_PACKAGE_NAME); $archive->close(); // Set progress Ai1wm_Status::info(__('Done adding configuration to archive.', AI1WM_PLUGIN_NAME)); return $params; }
function updateOptions() { $args = array('posts_per_page' => 1, 'post_type' => 'shop_options'); $opt_post = get_posts($args); $opt_to_rewrite = array('woocommerce_enable_myaccount_registration', 'yith_woocompare_is_button', 'yith_woocompare_compare_button_in_products_list', 'yith_woocompare_auto_open', 'yith_woocompare_price_end', 'yith_woocompare_add_to_cart_end', 'yith_wcwl_use_cookie', 'yith_wcwl_wishlist_title', 'yith_wcwl_use_button', 'yith_wcwl_socials_title', 'woocommerce_default_country', 'woocommerce_currency', 'woocommerce_shop_page_id', 'woocommerce_cart_page_id', 'woocommerce_checkout_page_id', 'woocommerce_pay_page_id', 'woocommerce_thanks_page_id', 'woocommerce_myaccount_page_id', 'woocommerce_edit_address_page_id', 'woocommerce_view_order_page_id', 'woocommerce_change_password_page_id', 'woocommerce_logout_page_id', 'woocommerce_lost_password_page_id', 'woocommerce_default_catalog_orderby'); $s_opt_to_rewrite = array('yith_woocompare_image_size', 'shop_catalog_image_size', 'shop_single_image_size', 'shop_thumbnail_image_size'); if ($opt_post) { $all_options = wp_load_alloptions(); foreach ($opt_post as $post) { foreach ($all_options as $name => $value) { if (in_array($name, $opt_to_rewrite)) { update_post_meta($post->ID, $name, $value); } elseif (in_array($name, $s_opt_to_rewrite)) { $value = unserialize($value); update_post_meta($post->ID, $name, $value); } } } } }
/** * @since 0.0.3 */ function blipper_widget_uninstall() { if (current_user_can('edit_plugins')) { // Delete options in database $option_name = 'blipper-widget-settings-oauth'; delete_option($option_name); // For site options in multi-site: delete_site_option($option_name); // Unregister the widget unregister_widget('Blipper_Widget'); // Clean up widget options $sidebar_widgets = get_option('sidebars_widgets'); foreach ($sidebar_widgets as $key => $value) { if (is_array($value)) { foreach ($value as $inner_key => $inner_value) { if (false !== strpos($inner_value, 'blipper_widget')) { // Don't want to mess with any widget that isn't the Blipper Widget. unset($sidebar_widgets[$key][$value]); } } // Tidy up the array $sidebar_widgets[$key] = array_values($sidebar_widgets[$key]); } } update_option('sidebars_widgets', $sidebar_widgets); // Delete orphaned options $all_options = wp_load_alloptions(); foreach ($all_options as $key => $value) { if (false !== strpos($key, 'blipper_widget')) { delete_option($key); // For site options in multi-site: delete_site_option($key); } if (false !== strpos($key, 'blipper-widget')) { delete_option($key); // For site options in multi-site: delete_site_option($key); } } } }
function aa_func_20153529023505() { $assets = get_template_directory_uri() . "/assets"; /** * ==================== Stylesheets ====================== */ wp_enqueue_style('aa-bootstrap-style', $assets . '/vendor/bootstrap-sass/assets/stylesheets/bootstrap.css'); wp_enqueue_style('aa-font-awesome', $assets . '/vendor/font-awesome/scss/font-awesome.css'); wp_enqueue_style('aa-vendors', $assets . '/vendor/vendors.css'); wp_enqueue_style('template-base-styles', get_bloginfo('stylesheet_url')); /** * ==================== Javascipts ====================== */ // jQuery JavaScript Library v2.1.4 wp_deregister_script('jquery'); wp_register_script('jquery', $assets . '/vendor/jquery/dist/jquery.min.js', array(), false, true); wp_enqueue_script('jquery'); /** * ==================== tmp dev scripts ====================== */ $tmpboofer = $assets . '/js/_boofer/'; wp_enqueue_script('aa-bootstrap', $tmpboofer . 'bootstrap-uglify.js', array(), false, true); wp_enqueue_script('aa-ng-components', $tmpboofer . 'angular-components.js', array(), false, true); wp_enqueue_script('aa-ng-mvc', $tmpboofer . 'angular-mvc-uglify.js', array(), false, true); $all_opts = wp_load_alloptions(); $site_options = ['blogname' => $all_opts['blogname'], 'blogdescription' => $all_opts['blogdescription'], 'admin_email' => $all_opts['admin_email'], 'show_on_front' => $all_opts['show_on_front'], 'page_on_front' => $all_opts['page_on_front'], 'page_for_posts' => aa_getpostslugbyid($all_opts['page_for_posts']), 'posts_per_page' => $all_opts['posts_per_page'], 'active_plugins' => join('|', unserialize($all_opts['active_plugins']))]; $ajax_data = array('site_url' => get_site_url(), 'ajax_url' => admin_url('admin-ajax.php'), 'template_uri' => get_template_directory_uri(), 'plugins_url' => plugins_url(), 'site_options' => $site_options, 'woo_opts' => aa_woocommerce_options(), 'current_user_id' => get_current_user_id(), 'current_user_avatar' => false); if (is_user_logged_in()) { $current_user = wp_get_current_user(); $ajax_data['current_user_avatar'] = get_avatar_url(get_current_user_id()); $ajax_data['user_login'] = $current_user->user_login; $ajax_data['user_email'] = $current_user->user_email; } wp_localize_script('aa-ng-mvc', 'aa_ajax_var', $ajax_data); /** * ==================== Production Script ====================== * Include after compile */ // wp_enqueue_script( 'aa-site-scrips', $assets . '/js/site-scripts.js', array(), false, true ); // wp_localize_script( 'aa-site-scrips', 'aa_ajax_var', $ajax_data ); }
function cc_update_old_version() { if (get_option('cc_version') <= 1.8) { $options = wp_load_alloptions(); foreach ((array) $options as $kay => $value) { $kay = esc_attr($kay); if (substr($kay, 0, 4) == 'cap_') { $cap = get_option('custom_community_theme_options'); $cap[$kay] = $value; update_option('custom_community_theme_options', $cap); delete_option($kay); } } update_option('cc_version', 1.9); } else { if (!get_option('cc_version')) { cap_defaults_init(); update_option('cc_version', 1.9); } } }
/** * @action widget_init, 90 */ function fix_widget_options() { /** * @var \wpdb $wpdb */ global $wpdb; /** * @var \WP_Widget_Factory $wp_widget_factory */ global $wp_widget_factory; $alloptions = wp_load_alloptions(); if (!is_array($alloptions)) { $this->plugin->trigger_warning(sprintf('wp_load_alloptions() did not return an array but a "%s"; object cache may be corrupted and may need to be flushed. Please follow https://core.trac.wordpress.org/ticket/31245', gettype($alloptions))); $alloptions = array(); } $autoloaded_option_names = array_keys($alloptions); $pending_unautoload_option_names = array(); foreach ($wp_widget_factory->widgets as $widget_obj) { /** * @var \WP_Widget $widget_obj */ $is_already_autoloaded = in_array($widget_obj->option_name, $autoloaded_option_names); if ($is_already_autoloaded) { // Add to list of options that we need to unautoload $pending_unautoload_option_names[] = $widget_obj->option_name; } else { // Preemptively do add_option() before the widget will ever have a chance to update_option() add_option($widget_obj->option_name, array(), '', 'no'); } } // Unautoload options and flush alloptions cache. if (!empty($pending_unautoload_option_names)) { $sql_in = join(',', array_fill(0, count($pending_unautoload_option_names), '%s')); $sql = "UPDATE {$wpdb->options} SET autoload = 'no' WHERE option_name IN ( {$sql_in} )"; $wpdb->query($wpdb->prepare($sql, $pending_unautoload_option_names)); // db call okay; cache okay wp_cache_delete('alloptions', 'options'); } }