本文整理汇总了PHP中wp_set_sidebars_widgets函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_set_sidebars_widgets函数的具体用法?PHP wp_set_sidebars_widgets怎么用?PHP wp_set_sidebars_widgets使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_set_sidebars_widgets函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: retrieve_widgets
function retrieve_widgets()
{
global $wp_registered_widget_updates, $wp_registered_sidebars, $sidebars_widgets, $wp_registered_widgets;
$_sidebars_widgets = array();
$sidebars = array_keys($wp_registered_sidebars);
unset($sidebars_widgets['array_version']);
$old = array_keys($sidebars_widgets);
sort($old);
sort($sidebars);
if ($old == $sidebars) {
return;
}
// Move the known-good ones first
foreach ($sidebars as $id) {
if (array_key_exists($id, $sidebars_widgets)) {
$_sidebars_widgets[$id] = $sidebars_widgets[$id];
unset($sidebars_widgets[$id], $sidebars[$id]);
}
}
// if new theme has less sidebars than the old theme
if (!empty($sidebars_widgets)) {
foreach ($sidebars_widgets as $lost => $val) {
if (is_array($val)) {
$_sidebars_widgets['wp_inactive_widgets'] = array_merge((array) $_sidebars_widgets['wp_inactive_widgets'], $val);
}
}
}
// discard invalid, theme-specific widgets from sidebars
$shown_widgets = array();
foreach ($_sidebars_widgets as $sidebar => $widgets) {
if (!is_array($widgets)) {
continue;
}
$_widgets = array();
foreach ($widgets as $widget) {
if (isset($wp_registered_widgets[$widget])) {
$_widgets[] = $widget;
}
}
$_sidebars_widgets[$sidebar] = $_widgets;
$shown_widgets = array_merge($shown_widgets, $_widgets);
}
$sidebars_widgets = $_sidebars_widgets;
unset($_sidebars_widgets, $_widgets);
// find hidden/lost multi-widget instances
$lost_widgets = array();
foreach ($wp_registered_widgets as $key => $val) {
if (in_array($key, $shown_widgets, true)) {
continue;
}
$number = preg_replace('/.+?-([0-9]+)$/', '$1', $key);
if (2 > (int) $number) {
continue;
}
$lost_widgets[] = $key;
}
$sidebars_widgets['wp_inactive_widgets'] = array_merge($lost_widgets, (array) $sidebars_widgets['wp_inactive_widgets']);
wp_set_sidebars_widgets($sidebars_widgets);
}
开发者ID:klr2003,项目名称:sourceread,代码行数:59,代码来源:widgets.php
示例2: ht_sidebars_page
/**
*
* HighThemes Options Framework
* twitter : http://twitter.com/theHighthemes
*
*/
function ht_sidebars_page()
{
global $sidehook, $sidebar_options, $wpdb;
if (isset($_POST['Submit'])) {
// getting the list of custom sidebars
$get_sidebar_options = ht_sidebar_generator::get_sidebars();
$sidebar_name = str_replace(array("\n", "\r", "\t"), '', $_POST['ht_sidebar_name']);
$sidebar_id = sanitize_title($sidebar_name);
if ($sidebar_id == '') {
$options_sidebar = $get_sidebar_options;
} else {
if (isset($get_sidebar_options[$sidebar_id])) {
header("Location: admin.php?page=sidebars&error=true{$hidden_anchor}");
die;
}
if (is_array($get_sidebar_options)) {
$new_sidebar_gen[$sidebar_id] = $sidebar_name;
$options_sidebar = array_merge($get_sidebar_options, (array) $new_sidebar_gen);
} else {
$options_sidebar[$sidebar_id] = $sidebar_name;
}
}
update_option('ht_sidebar_generator', $options_sidebar);
header("Location: admin.php?page=sidebars{$send}&saved=true{$hidden_anchor}");
die;
}
if (isset($_GET['sn'])) {
$sidebar_id = $_GET['sn'];
$get_sidebar_options = ht_sidebar_generator::get_sidebars();
if (array_key_exists($sidebar_id, $get_sidebar_options)) {
unset($get_sidebar_options[$sidebar_id]);
update_option('ht_sidebar_generator', $get_sidebar_options);
//
$get_widgets = wp_get_sidebars_widgets();
unset($get_widgets['array_version']);
foreach ($get_widgets as $key => $value) {
if ($key == 'ht_' . $sidebar_id) {
unset($get_widgets['ht_' . $sidebar_id]);
}
}
wp_set_sidebars_widgets($get_widgets);
$sidebar_meta = $wpdb->get_results("SELECT post_id FROM {$wpdb->postmeta} WHERE meta_value = '{$sidebar_id}'", ARRAY_A);
if ($sidebar_meta) {
if (is_array($sidebar_meta)) {
foreach ($sidebar_meta as $key => $value) {
delete_post_meta($value['post_id'], '_selected_sidebar');
}
}
} else {
header("Location: admin.php?page=sidebars");
}
}
}
wp_enqueue_script('common');
wp_enqueue_script('wp-lists');
wp_enqueue_script('postbox');
add_meta_box('ht_add_sidebars', 'Add New Sidebars', 'ht_add_sidebars', $sidehook, 'normal', 'high');
}
开发者ID:naffan2014,项目名称:greenhomeland,代码行数:64,代码来源:sidebars.php
示例3: import_widgets
function import_widgets($file)
{
$data = unserialize(base64_decode(file_get_contents($file)));
$data['positions']['wp_inactive_widgets'] = array();
wp_set_sidebars_widgets($data['positions']);
foreach ($data['widgets'] as $class => $widget) {
update_option($class, $widget);
}
}
开发者ID:amitmula,项目名称:amitandaastha.in,代码行数:9,代码来源:importer.php
示例4: clear_widgets
private static function clear_widgets()
{
$sidebars = wp_get_sidebars_widgets();
$inactive = isset($sidebars['wp_inactive_widgets']) ? $sidebars['wp_inactive_widgets'] : array();
unset($sidebars['wp_inactive_widgets']);
foreach ($sidebars as $sidebar => $widgets) {
$inactive = array_merge($inactive, $widgets);
$sidebars[$sidebar] = array();
}
$sidebars['wp_inactive_widgets'] = $inactive;
wp_set_sidebars_widgets($sidebars);
}
开发者ID:taeche,项目名称:SoDoEx,代码行数:12,代码来源:class-widget-data.php
示例5: on_ecwid_plugin_installed
public function on_ecwid_plugin_installed()
{
$widgets = get_option('sidebars_widgets');
if (strpos(implode(' ', $widgets['sidebar-1']), 'ecwidstorelink') === false) {
array_unshift($widgets['sidebar-1'], 'ecwidstorelink-2');
wp_set_sidebars_widgets($widgets);
$options = get_option('widget_ecwidstorelink');
if (!$options) {
$options = array(2 => array('label' => __('Shop', 'ecwid-shopping-cart')), '_multiwidget' => 1);
}
update_option('widget_ecwidstorelink', $options);
}
}
开发者ID:digitaldevelopers,项目名称:ecwid-wordpress-plugin,代码行数:13,代码来源:class-ecwid-theme-twentyfifteen.php
示例6: import_sidebars_widgets
public function import_sidebars_widgets($file)
{
$thememove_sidebars = get_option("sidebars_widgets");
unset($thememove_sidebars['array_version']);
$data = $this->file_options($file);
if (is_array($data['sidebars'])) {
$thememove_sidebars = array_merge((array) $thememove_sidebars, (array) $data['sidebars']);
unset($thememove_sidebars['wp_inactive_widgets']);
$thememove_sidebars = array_merge(array('wp_inactive_widgets' => array()), $thememove_sidebars);
$thememove_sidebars['array_version'] = 2;
wp_set_sidebars_widgets($thememove_sidebars);
}
}
开发者ID:novichkovv,项目名称:prlab,代码行数:13,代码来源:import.php
示例7: rotary_install_default_widgets
function rotary_install_default_widgets()
{
//add default widgets to the home page side bar
$sidebar = 'home-widget-area';
$widget_name = 'text';
$sidebars_widgets = wp_get_sidebars_widgets();
if (empty($sidebars_widgets[$sidebar])) {
$sidebar_options = get_option('widget_' . $widget_name);
$startcount = $count = count($sidebar_options);
$sidebar_options[$count] = array('title' => 'Rotary Vision', 'text' => '', 'filter' => '');
$count++;
$sidebar_options[$count] = array('title' => 'Rotary Mission', 'text' => '', 'filter' => '');
$count++;
$sidebar_options[$count] = array('title' => 'Project Filters', 'text' => '', 'filter' => '');
$count++;
$sidebar_options[$count] = array('title' => '4-Way Test', 'text' => '', 'filter' => '');
update_option('widget_' . $widget_name, $sidebar_options);
$sidebars_widgets[$sidebar] = array();
for ($i = $startcount; $i <= $count; $i++) {
$sidebars_widgets[$sidebar][] = $widget_name . '-' . $i;
}
//add the rotary blogroll
$widget_name = 'rotarylinks';
$sidebar_options = get_option('widget_' . $widget_name);
$count = count($sidebar_options);
$sidebar_options[$count] = array('images' => 0, 'name' => '', 'description' => '', 'rating' => 0, 'orderby' => 0, 'limit' => 0);
update_option('widget_' . $widget_name, $sidebar_options);
$sidebars_widgets[$sidebar][] = $widget_name . '-' . $count;
wp_set_sidebars_widgets($sidebars_widgets);
}
//add default widgets to the secondary side bar
$sidebar = 'secondary-widget-area';
$widget_name = 'rotaryarchivewidget';
$sidebars_widgets = wp_get_sidebars_widgets();
if (empty($sidebars_widgets[$sidebar])) {
$sidebar_options = get_option('widget_' . $widget_name);
$count = count($sidebar_options);
$sidebar_options[$count] = array('title' => 'Archives', 'showcount' => 0, 'linkcounter' => 0, 'truncmonth' => 0, 'jsexpand' => 1, 'groupbyyear' => 1, 'limitbycategory' => 0);
$sidebars_widgets[$sidebar] = array();
update_option('widget_' . $widget_name, $sidebar_options);
$sidebars_widgets[$sidebar][] = $widget_name . '-' . $count;
//add the tag cloud
$widget_name = 'tag_cloud';
$sidebar_options = get_option('widget_' . $widget_name);
$count = count($sidebar_options);
$sidebar_options[$count] = array('title' => 'Tags', 'taxonomy' => '');
update_option('widget_' . $widget_name, $sidebar_options);
$sidebars_widgets[$sidebar][] = $widget_name . '-' . $count;
wp_set_sidebars_widgets($sidebars_widgets);
}
}
开发者ID:bogdanbrudiu,项目名称:rotary,代码行数:51,代码来源:sidebar-init.php
示例8: set_ls_sidebar
public function set_ls_sidebar()
{
$counter = $this->get_widget_index();
$language_switcher_prefix = 'icl_lang_sel_widget-';
$active_widgets = get_option('sidebars_widgets');
foreach ($this->ls_sidebars as $target_sidebar_id => $add_widget) {
$active_sidebar_widgets = $active_widgets[$target_sidebar_id];
$widget_exists = $this->widget_exists($language_switcher_prefix, $active_sidebar_widgets);
if ($add_widget && !$widget_exists) {
$active_widgets = $this->add_to_sidebar($active_widgets, $target_sidebar_id, $language_switcher_prefix, $counter);
$counter = $this->update_widget_options($counter);
} elseif (!$add_widget && $widget_exists) {
$active_widgets = $this->remove_widget($active_sidebar_widgets, $language_switcher_prefix, $active_widgets, $target_sidebar_id);
}
}
wp_set_sidebars_widgets($active_widgets);
}
开发者ID:edgarter,项目名称:wecare,代码行数:17,代码来源:wpml-language-switcher-settings.class.php
示例9: fastfood_upgrade
/**
* Update some mods and options
*
* @since Fastfood 0.37
*/
function fastfood_upgrade()
{
if (!is_admin()) {
return;
}
$options_version = get_theme_mod('options_version', '0.36');
if (version_compare($options_version, '0.37', '<')) {
// footer widget area
$sidebars_widgets = get_option('sidebars_widgets', array());
$_sidebars_widgets = array();
foreach (array('first-footer-widget-area', 'second-footer-widget-area', 'third-footer-widget-area') as $sidebar) {
if (isset($sidebars_widgets[$sidebar])) {
$_sidebars_widgets = array_merge($_sidebars_widgets, $sidebars_widgets[$sidebar]);
unset($sidebars_widgets[$sidebar]);
}
}
$sidebars_widgets['footer-widget-area'] = $_sidebars_widgets;
wp_set_sidebars_widgets($sidebars_widgets);
// header slider
$header_image = get_theme_mod('header_image');
if ($header_image === 'fastfood-slider-uploaded') {
set_theme_mod('header_image', '');
set_theme_mod('display_header_slider', 1);
}
// quickbar-navbar icons
$background_color = get_theme_mod('background_color');
$iconfont_color = get_theme_mod('background_icons_color');
if ($background_color && !$iconfont_color) {
$r = hexdec(substr($background_color, 0, 2));
$g = hexdec(substr($background_color, 2, 2));
$b = hexdec(substr($background_color, 4, 2));
$yiq = ($r * 299 + $g * 587 + $b * 114) / 1000;
$iconfont_color = $yiq >= 120 ? '#404040' : '#FFFFFF';
set_theme_mod('background_icons_color', $iconfont_color);
}
// header text background
$header_text_background = get_theme_mod('header_text_background');
if ($header_text_background) {
$match = array('transparent' => 'transparent', 'black' => '#000000', 'white' => '#FFFFFF');
$header_text_background = isset($match[$header_text_background]) ? $match[$header_text_background] : 'transparent';
set_theme_mod('header_text_background', $header_text_background);
}
}
set_theme_mod('options_version', fastfood_get_info('version'));
}
开发者ID:TwoBeers,项目名称:fastfood,代码行数:50,代码来源:back-compat.php
示例10: wps_upgrade
function wps_upgrade($current_version)
{
global $wpdb;
$table_name = $wpdb->prefix . "category_subdomains";
//--- Run upgrades based on current version
switch ($current_version) {
case '':
$wpdb->query("UPDATE " . $table_name . " SET is_subdomain = 1 WHERE not_subdomain = 0");
$wpdb->query("UPDATE " . $table_name . " SET not_subdomain = 0");
// Change options from old SR ones to CSD ones.
update_option('csd_sub_pages', get_option('sr_sub_pages') ? get_option('sr_sub_pages') : '');
update_option('csd_themes_on', get_option('sr_themes_on') ? get_option('sr_themes_on') : '');
update_option('csd_catarchives_on', get_option('sr_catarchives_on') ? get_option('sr_catarchives_on') : '');
update_option('csd_pagefilter_on', get_option('sr_pagefilter_on') ? get_option('sr_pagefilter_on') : '');
case '0.5.0':
// Change options to new names and settings
update_option('wps_sub_pages', get_option('csd_sub_pages') ? WPS_CHK_ON : '');
update_option('wps_themes', get_option('csd_themes_on') ? WPS_CHK_ON : '');
update_option('wps_catarchives', get_option('csd_catarchives_on') ? WPS_CHK_ON : '');
update_option('wps_pagefilter', get_option('csd_pagefilter_on') ? WPS_CHK_ON : '');
update_option('wps_subdomainall', get_option('csd_subdomainall_on') ? WPS_CHK_ON : '');
// Delete Old CSD options, leave the SR options so they can go back to old plugin
delete_option('csd_themes_on');
delete_option('csd_catarchives_on');
delete_option('csd_pagefilter_on');
delete_option('csd_subdomainall_on');
// Change page meta keys to new ones
$wpdb->query("UPDATE " . $wpdb->postmeta . " SET meta_key = 'wps_page_theme' WHERE meta_key = 'csd_page_theme'");
$wpdb->query("UPDATE " . $wpdb->postmeta . " SET meta_key = 'wps_page_subdomain' WHERE meta_key = 'csd_page_subdomain'");
$wpdb->query("UPDATE " . $wpdb->postmeta . " SET meta_key = 'wps_tie_to_category' WHERE meta_key = 'csd_tie_to_category'");
case '0.5.1':
// Change Widgets Names to the New Names
$widgets = wp_get_sidebars_widgets();
foreach (array_keys($widgets) as $sidebar) {
if ($key = array_search('csd-site-list', $widgets[$sidebar])) {
$widgets[$sidebar][$key] = 'wps-sitelist';
}
if ($key = array_search('csd-categories', $widgets[$sidebar])) {
$widgets[$sidebar][$key] = 'wps-categories';
}
}
wp_set_sidebars_widgets($widgets);
break;
}
}
开发者ID:hacklabr,项目名称:toquenobrasil,代码行数:45,代码来源:install.php
示例11: import_widgets
function import_widgets($folder = '', $file = 'widgets.txt')
{
$file_path = get_template_directory() . '/library/import/files/' . $folder . '/' . $file;
$file_data = $this->get_file_contents($file_path);
$data = json_decode($file_data, true);
foreach ((array) $data['widgets'] as $widget_id => $widget_data) {
update_option('widget_' . $widget_id, $widget_data);
}
$slice_sidebars = get_option("sidebars_widgets");
unset($slice_sidebars['array_version']);
if (is_array($data['sidebars'])) {
$slice_sidebars = array_merge((array) $slice_sidebars, (array) $data['sidebars']);
unset($slice_sidebars['wp_inactive_widgets']);
$slice_sidebars = array_merge(array('wp_inactive_widgets' => array()), $slice_sidebars);
$slice_sidebars['array_version'] = 2;
wp_set_sidebars_widgets($slice_sidebars);
}
}
开发者ID:love4code,项目名称:originalContracting,代码行数:18,代码来源:import.php
示例12: mr_upgrade_to_4_0
/**
* Upgrade to 4.0
*/
function mr_upgrade_to_4_0()
{
try {
$sidebar_widgets = wp_get_sidebars_widgets();
foreach ($sidebar_widgets as &$widgets) {
foreach ($widgets as $widget_key => $widget_id) {
if (strpos($widget_id, 'top_rating_results_widget') !== false) {
$instance = substr($widget_id, 26);
$widget_id = 'mr_rating_results_list-' . $instance;
$widget_options = get_option('widget_top_rating_results_widget');
$show_filter = $widget_options[$instance]['show_category_filter'];
$term_id = $widget_options[$instance]['category_id'];
unset($widget_options[$instance]['show_category_filter']);
$widget_options[$instance]['show_filter'] = $show_filter;
unset($widget_options[$instance]['category_id']);
$widget_options[$instance]['term_id'] = $term_id;
$widget_options[$instance]['taxonomy'] = 'category';
add_option('widget_mr_rating_results_list', $widget_options);
delete_option('widget_top_rating_results_widget');
$widgets[$widget_key] = $widget_id;
}
}
}
// custom settings
$custom_text_settings = (array) get_option(Multi_Rating::CUSTOM_TEXT_SETTINGS);
if (isset($custom_text_settings['mr_category_label_text'])) {
$custom_text_settings[Multi_Rating::FILTER_LABEL_TEXT_OPTION] = $custom_text_settings['mr_category_label_text'];
unset($custom_text_settings['mr_category_label_text']);
}
if (isset($custom_text_settings['mr_top_rating_results_title_text'])) {
$custom_text_settings[Multi_Rating::RATING_RESULTS_LIST_TITLE_TEXT_OPTION] = $custom_text_settings['mr_top_rating_results_title_text'];
unset($custom_text_settings['mr_top_rating_results_title_text']);
}
update_option(Multi_Rating::CUSTOM_TEXT_SETTINGS, $custom_text_settings);
// PHP files
if (file_exists(dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'class-rating-result.php')) {
unlink(dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'class-rating-result.php');
}
} catch (Exception $e) {
die(__('An error occured.', 'multi-rating'));
}
wp_set_sidebars_widgets($sidebar_widgets);
}
开发者ID:ratheeshpkr,项目名称:multi-rating,代码行数:46,代码来源:update-check.php
示例13: gk_set_sidebar_default
function gk_set_sidebar_default()
{
global $_wp_sidebars_widgets;
//初始化widget
$widgets = gk_config('widget');
foreach ($widgets as $name => $setting) {
$id = 102;
$option = get_option('widget_' . $name);
if (!$option) {
$option = array();
}
if (!isset($option[$id]) || gk_config('sidebar_debug')) {
$option[$id] = $setting;
update_option('widget_' . $name, $option);
}
}
//初始化边栏
$sidebars_option = wp_get_sidebars_widgets();
$update_sidebar = true;
$sidebars = gk_config('sidebar');
foreach ($sidebars as $sidebar) {
if (isset($sidebar['default']) && (!isset($sidebars_option[$sidebar['id']]) || gk_config('sidebar_debug'))) {
$sidebars_option[$sidebar['id']] = array_map(create_function('$v', 'return $v.\'-102\';'), explode(',', $sidebar['default']));
$update_sidebar = true;
}
}
if ($update_sidebar) {
$_wp_sidebars_widgets = $sidebars_option;
wp_set_sidebars_widgets($sidebars_option);
}
}
开发者ID:G-g-beringei,项目名称:DChaser,代码行数:31,代码来源:functions.php
示例14: retrieve_widgets
function retrieve_widgets($theme_changed = false)
{
global $wp_registered_widget_updates, $wp_registered_sidebars, $sidebars_widgets, $wp_registered_widgets;
$registered_sidebar_keys = array_keys($wp_registered_sidebars);
$orphaned = 0;
$old_sidebars_widgets = get_theme_mod('sidebars_widgets');
if (is_array($old_sidebars_widgets)) {
// time() that sidebars were stored is in $old_sidebars_widgets['time']
$_sidebars_widgets = $old_sidebars_widgets['data'];
remove_theme_mod('sidebars_widgets');
foreach ($_sidebars_widgets as $sidebar => $widgets) {
if ('wp_inactive_widgets' == $sidebar || 'orphaned_widgets' == substr($sidebar, 0, 16)) {
continue;
}
if (!in_array($sidebar, $registered_sidebar_keys)) {
$_sidebars_widgets['orphaned_widgets_' . ++$orphaned] = $widgets;
unset($_sidebars_widgets[$sidebar]);
}
}
} else {
if (empty($sidebars_widgets)) {
return;
}
unset($sidebars_widgets['array_version']);
$old = array_keys($sidebars_widgets);
sort($old);
sort($registered_sidebar_keys);
if ($old == $registered_sidebar_keys) {
return;
}
$_sidebars_widgets = array('wp_inactive_widgets' => !empty($sidebars_widgets['wp_inactive_widgets']) ? $sidebars_widgets['wp_inactive_widgets'] : array());
unset($sidebars_widgets['wp_inactive_widgets']);
foreach ($wp_registered_sidebars as $id => $settings) {
if ($theme_changed) {
$_sidebars_widgets[$id] = array_shift($sidebars_widgets);
} else {
// no theme change, grab only sidebars that are currently registered
if (isset($sidebars_widgets[$id])) {
$_sidebars_widgets[$id] = $sidebars_widgets[$id];
unset($sidebars_widgets[$id]);
}
}
}
foreach ($sidebars_widgets as $val) {
if (is_array($val) && !empty($val)) {
$_sidebars_widgets['orphaned_widgets_' . ++$orphaned] = $val;
}
}
}
// discard invalid, theme-specific widgets from sidebars
$shown_widgets = array();
foreach ($_sidebars_widgets as $sidebar => $widgets) {
if (!is_array($widgets)) {
continue;
}
$_widgets = array();
foreach ($widgets as $widget) {
if (isset($wp_registered_widgets[$widget])) {
$_widgets[] = $widget;
}
}
$_sidebars_widgets[$sidebar] = $_widgets;
$shown_widgets = array_merge($shown_widgets, $_widgets);
}
$sidebars_widgets = $_sidebars_widgets;
unset($_sidebars_widgets, $_widgets);
// find hidden/lost multi-widget instances
$lost_widgets = array();
foreach ($wp_registered_widgets as $key => $val) {
if (in_array($key, $shown_widgets, true)) {
continue;
}
$number = preg_replace('/.+?-([0-9]+)$/', '$1', $key);
if (2 > (int) $number) {
continue;
}
$lost_widgets[] = $key;
}
$sidebars_widgets['wp_inactive_widgets'] = array_merge($lost_widgets, (array) $sidebars_widgets['wp_inactive_widgets']);
wp_set_sidebars_widgets($sidebars_widgets);
return $sidebars_widgets;
}
开发者ID:CarterNelms,项目名称:www.engineeredcomfort.net,代码行数:82,代码来源:widgets.php
示例15: ob_start
ob_start();
call_user_func_array($control['callback'], $control['params']);
ob_end_clean();
break;
}
$sidebars_widgets[$sidebar_id] = $sidebar;
// Remove old position.
if (!isset($_POST['delete_widget'])) {
foreach ($sidebars_widgets as $key => $sb) {
if (is_array($sb)) {
$sidebars_widgets[$key] = array_diff($sb, array($widget_id));
}
}
array_splice($sidebars_widgets[$sidebar_id], $position, 0, $widget_id);
}
wp_set_sidebars_widgets($sidebars_widgets);
wp_redirect(admin_url('widgets.php?message=0'));
exit;
}
// Output the widget form without js
if (isset($_GET['editwidget']) && $_GET['editwidget']) {
$widget_id = $_GET['editwidget'];
if (isset($_GET['addnew'])) {
// Default to the first sidebar
$keys = array_keys($wp_registered_sidebars);
$sidebar = array_shift($keys);
if (isset($_GET['base']) && isset($_GET['num'])) {
// multi-widget
// Copy minimal info from an existing instance of this widget to a new instance
foreach ($wp_registered_widget_controls as $control) {
if ($_GET['base'] === $control['id_base']) {
开发者ID:luskyj89,项目名称:mt-wordpress,代码行数:31,代码来源:widgets.php
示例16: process_sidebar_update
/**
* Process submissions for the Edit Sidebar screen.
*
* Handles cases where the sidebar is renamed, reassigns pages, and
* removes the sidebar if no pages are selected. Requires a valid nonce.
*
* @since 1.1.0
*/
public static function process_sidebar_update()
{
global $wpdb;
if (isset($_POST['simplepagesidebars_sidebar_name'])) {
$current_name = stripslashes($_POST['simplepagesidebars_sidebar_name']);
check_admin_referer('update-sidebar_' . $current_name, 'simplepagesidebars_sidebar_update_nonce');
$new_name = stripslashes($_POST['simplepagesidebars_sidebar_name_new']);
$new_name = !empty($new_name) && $new_name != $current_name ? trim(wp_strip_all_tags($new_name)) : null;
$pages = isset($_POST['simplepagesidebars_sidebar_pages']) ? wp_parse_id_list($_POST['simplepagesidebars_sidebar_pages']) : array();
// Retrieve IDs of pages using the existing sidebar name.
$current_pages = self::get_page_ids_using_sidebar($current_name);
// Pages to reset to the default sidebar.
$reset_pages = array_diff($current_pages, $pages);
if ($reset_pages) {
foreach ($reset_pages as $page_id) {
delete_post_meta($page_id, '_sidebar_name');
}
}
// Update all sidebars if there is a new sidebar name.
if ($new_name) {
$wpdb->query($wpdb->prepare("UPDATE {$wpdb->postmeta} SET meta_value=%s WHERE meta_key='_sidebar_name' AND meta_value=%s", $new_name, $current_name));
} elseif ($update_pages = array_diff($pages, $current_pages)) {
foreach ($update_pages as $page_id) {
update_post_meta($page_id, '_sidebar_name', addslashes($current_name));
}
}
// The sidebar should have been removed from all pages.
// Let WordPress move widgets to Inactive Sidebar, redirect to Widgets screen, and notify user.
if (empty($pages)) {
wp_safe_redirect(esc_url_raw(add_query_arg('simple-page-sidebars-message', 1, admin_url('widgets.php'))));
exit;
}
// Migrate widgets if the sidebar name was changed.
if ($new_name) {
$sidebars_widgets = wp_get_sidebars_widgets();
$old_id = 'page-sidebar-' . sanitize_key($current_name);
$new_id = 'page-sidebar-' . sanitize_key($new_name);
// If new id matches an existing id, merge old widgets with new.
if (isset($sidebars_widgets[$new_id])) {
$sidebars_widgets[$new_id] = array_merge($sidebars_widgets[$new_id], $sidebars_widgets[$old_id]);
} elseif (isset($sidebars_widgets[$old_id])) {
$sidebars_widgets[$new_id] = $sidebars_widgets[$old_id];
}
// Remove old widget area and save.
unset($sidebars_widgets[$old_id]);
#echo '<pre>'; print_r( $sidebars_widgets ); echo '</pre>'; exit;
wp_set_sidebars_widgets($sidebars_widgets);
}
// Redirect back to sidebar edit screen with an update message.
$name = !empty($new_name) ? $new_name : $current_name;
$redirect_link = self::get_sidebar_edit_link($name, array('message' => 1));
wp_safe_redirect(esc_url_raw($redirect_link));
exit;
}
}
开发者ID:bchamberlain88,项目名称:pavati,代码行数:63,代码来源:admin.php
示例17: update_option
}
update_option('widget_' . $language_switcher_name, $language_switcher_content);
$counter++;
$active_widgets[$target_sidebar_id] = $active_sidebar_widgets;
$update_sidebars_widgets = true;
} elseif (!$add_widget && $widget_exists) {
foreach ($active_sidebar_widgets as $index => $active_sidebar_widget) {
if (strpos($active_sidebar_widget, $language_switcher_prefix) !== false) {
unset($active_widgets[$target_sidebar_id][$index]);
$update_sidebars_widgets = true;
}
}
}
}
if ($update_sidebars_widgets) {
wp_set_sidebars_widgets($active_widgets);
}
}
$filtered_icl_lso_link_empty = filter_input(INPUT_POST, 'icl_lso_link_empty', FILTER_SANITIZE_NUMBER_INT, FILTER_NULL_ON_FAILURE);
$filtered_icl_lso_flags = filter_input(INPUT_POST, 'icl_lso_flags', FILTER_SANITIZE_NUMBER_INT, FILTER_NULL_ON_FAILURE);
$filtered_icl_lso_native_lang = filter_input(INPUT_POST, 'icl_lso_native_lang', FILTER_SANITIZE_NUMBER_INT, FILTER_NULL_ON_FAILURE);
$filtered_icl_lso_display_lang = filter_input(INPUT_POST, 'icl_lso_display_lang', FILTER_SANITIZE_NUMBER_INT, FILTER_NULL_ON_FAILURE);
$iclsettings['icl_lso_link_empty'] = intval($filtered_icl_lso_link_empty);
$iclsettings['icl_lso_flags'] = $filtered_icl_lso_flags !== false ? $filtered_icl_lso_flags : 0;
$iclsettings['icl_lso_native_lang'] = $filtered_icl_lso_native_lang !== false ? $filtered_icl_lso_native_lang : 0;
$iclsettings['icl_lso_display_lang'] = $filtered_icl_lso_display_lang !== false ? $filtered_icl_lso_display_lang : 0;
if (!$this->get_setting('setup_complete')) {
$iclsettings['setup_wizard_step'] = 4;
//$iclsettings['setup_complete'] = 1;
if (isset($iclsettings['setup_reset'])) {
unset($iclsettings['setup_reset']);
开发者ID:PHQ-Design,项目名称:souza-lima,代码行数:31,代码来源:ajax.php
示例18: set_sidebar_widgets
/**
* Sets the sidebar widgets
*
* @since 1.0.0
*/
private function set_sidebar_widgets($widgets)
{
$sidebar_widgets = wp_get_sidebars_widgets();
$sidebar_widgets['cherry-mega-menu'] = $widgets;
wp_set_sidebars_widgets($sidebar_widgets);
}
开发者ID:xav335,项目名称:sfnettoyage,代码行数:11,代码来源:class-cherry-mega-menu-widget-manager.php
示例19: add_default_widget
/**
* Add default widget upon successful theme activation.
*
* @since 0.1.0
*/
public static function add_default_widget($widget, $overwrite_widgets = false)
{
global $wpgo_connect_multi_number;
$multi_number = $wpgo_connect_multi_number;
$wpgo_connect_multi_number++;
$args = WPGo_UTILITY::get_widget_args($widget['widget_name']);
// returns an array
$id_base = $args['_id_base'];
$widget_number = $args['_widget_num'];
$widget_id = $id_base . '-' . $multi_number;
$widget_area = $widget['widget_area'];
/* Create widget. */
$add_new_widget = get_option('widget_' . $id_base);
$add_new_widget[$multi_number] = $widget['default_settings'];
$add_new_widget['_multiwidget'] = 1;
update_option('widget_' . $id_base, $add_new_widget);
/* Add to widget area. */
$add_to_sidebar = get_option('sidebars_widgets');
/* Overwrite (or just add to) existing widgets in the specified widget area. */
if ($overwrite_widgets) {
$add_to_sidebar[$widget_area] = array();
}
$add_to_sidebar[$widget_area][] = $widget_id;
wp_set_sidebars_widgets($add_to_sidebar);
}
开发者ID:vihoangson,项目名称:vihoangson.com,代码行数:30,代码来源:utility.php
示例20: delete_widget
/**
* Deletes a widget.
*
* @param string $widget_id The id of the widget to delete
*/
public static function delete_widget($widget_id)
{
global $wp_registered_widgets;
if (!isset($wp_registered_widgets[$widget_id])) {
return false;
}
$sidebars = wp_get_sidebars_widgets();
$sidebar_id = self::find_sidebar_for_widget($widget_id);
$sidebar = isset($sidebars[$sidebar_id]) ? $sidebars[$sidebar_id] : array();
$sidebar = array_diff($sidebar, array($widget_id));
$sidebars[$sidebar_id] = $sidebar;
wp_set_sidebars_widgets($sidebars);
return true;
}
开发者ID:trendwerk,项目名称:recurring-widgets,代码行数:19,代码来源:recurring-widgets.php
注:本文中的wp_set_sidebars_widgets函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论