Tag Info

New answers tagged

2

First of all I have to say taht after a quick investigations seems that no 'dashboard_right_now' or 'dashboard_quick_press' usermeta exists... so setting it to false like in you code can't do anything. That said according to the docs there's no way to specify where your widget shows up Docs lie. When an user logout and then login again, all widgets ...


3

The problem is pretty simple: Some widgets do have a title, while others don't. As long as the title filter is present, it works. Example of what the plugin might have: echo apply_filters( 'widget_title', $instance['title'] ); If that filter is not present, there won't be a title.


1

Yes it is, and this can be a very handy feature. The 'hiding place' for widgets is one of the least intuitive designs of the Wordpress backend, IMHO. You can use a plugin such as: Widgets on Pages Or perhaps a more up-to-date one such as Widgetize Pages Or you can build code yourself and place it elsewhere in the admin (such as the dashboard). A tutorial ...


0

This is what you're looking for: http://codex.wordpress.org/Plugin_API/Action_Reference/init Example from Codex: add_action('init', 'process_post'); function process_post(){ if(isset($_POST['unique_hidden_field'])) { // process $_POST data here } }


0

Firstly, you will need your code to store the exclude value somewhere. Since you don't want to use a global ( rightly so ), you have few remaining options: a class the class you already have a closure standard APIs Option 1 a new object/class Here we create an object, that holds the category you're excluding, and some logic to exclude it. class ...


0

First of all 'posts_where' filter (just like all other 'posts_*' filters) is not very reliable, because you assume that where clause is the standard one, but if other plugin use same filter before or after the your, result is not the expected, in best case, and in worst case you get only errors for bad sql query. After that, why use a filter when you can ...


0

I see two approaches to this, depending on rest of your architecture. Make filter part method of widget class, instead of function. Assign data to its object property internally and method will have clean access to it, without polluting global namespace. Make custom query variable. Pass your data to the WP_Query constructor and have filter function check ...


1

Yes, it is possible to unregister a widget area. Widget areas, also known as Dynamic Sidebars, are registered via register_sidebar(), which will look something like so: register_sidebar( array( 'name' => __( 'Sidebar name', 'theme_text_domain' ), 'id' => 'unique-sidebar-id', 'description' => '', 'class' => '', ...


2

No, is not possible, not in 99% of cases. Widget areas are added with a register_sidebar call in a php file. Until WordPress read that line, the widget area is registered. So, the the easiest and always available way to prevent a widget area is registered is remove (or at least comment out) that line. If the widget area is registered inside a theme ...


1

This is an Ajax thing. One solution to make your script work again when you save the widget: jQuery(document).ajaxSuccess(function(event, xhr, settings) { var widget_id_base = 'your-widget-id-base'; if(settings.data.search('action=save-widget') != -1 && settings.data.search('id_base=' + widget_id_base) != -1) { // Do you stuff again ...


1

Monster Widget is a bit of a trap like that. Despite how it looks it doesn't actually place "real" widgets into sidebar. It is a single widgets that creates output of other widgets inside of itself. If you are significantly interfering with its expectations then it won't pick up on changes, since it's not engineered to do it. You will likely need to use ...


0

After looking at the previous answers, I think I fixed the problem Cmorales identified with sanchothefat's answer. Define your widget as follows: register_sidebar( array( 'name' => 'Sidebar', 'id' => 'sidebar', 'before_widget' => '<div class="panel panel-default %2$s" id="%1$s">', 'after_widget' => '</div>', ...


1

Widget Context allows this as standard. You can select to only how on pages that more than or less than a set number of words!


0

I suspect this is mostly happening because down towards the bottom, you've got an input that's not using $this->get_field_name() (the first of the two checkbox inputs). Try using $this->get_field_name() as you did in the "then" clause of that section of code and it should be OK. Not much else wrong that I can see.


0

I believe that what you want to do would better be done with CSS rules in your stylesheet rather than with an embedded style tag that you dynamically manipulate with PHP. Remove style="visibility: hidden;" from your register_sidebar argument and use something like the following instead (Proof of Concept): <html> <head> <style> ...


1

Widget data is stored in the options table as a two dimensional array. All data for the same type of widget is stored under the same option key. The key of the outer array is a kind of widget "index"-- the identifier for the particular instance of the widget. The inner arrays contain the individual widget data. Like so: array(5) { // outer array ...


0

The constructor of widget is called when the widget is registered, so your add_action is called on (probably) every request. You can avoid that simply put the add_action inside widget() function, that is called only when the widget is printed so there is no need to check: just output what you want. Also, if you need some context inside the footer method you ...


0

Well, the very obvious way to shorten it is to simply avoid repeating yourself: ?> <div class="large-3 medium-3 columns"> <div class="panel"><?php if ( is_active_sidebar( 'available-course-list-1' ) ) { dynamic_sidebar( 'available-course-list-1' ); } else { ?> <h5>Available Course List #2</h5> ...


2

is_active_sidebar has a single value, whether it is the sideabar id or name. If you have more than one sidebar, you should repeat is_active_sidebar, each one with a specific sidebar id or name. You would do something like this <?php if ( is_active_sidebar( 'available-course-list-1' ) && is_active_sidebar( 'available-course-list-2' )) : ?>


3

There actually are filters coming with WP 3.9+: do_action( 'dynamic_sidebar_before', $index, false ); do_action( 'dynamic_sidebar_after', $index, false ); apply_filters( 'dynamic_sidebar_has_widgets', false, $index ); The 2nd argument indicates if the sidebar has widgets. Current workaround: Hook into sanitize_title() as this will hold the current ...


1

Place the following code above the DOCTYPE in header.php: <?php $bg = array('bg-01.jpg', 'bg-02.jpg', 'bg-03.jpg', 'bg-04.jpg', 'bg-05.jpg', 'bg-06.jpg', 'bg-07.jpg' ); // array of filenames $i = rand(0, count($bg)-1); // generate random number size of the array $selectedBg = "$bg[$i]"; // set variable equal to which random filename was chosen ...


0

Why you want to use ajax for showing some fields on form in widget? Can't it be done using simple show hide using jquery. See below. Not tested , just to give insight. HTML <input type="radio" id="someradio" /> <div id="somediv" style="display:none;"> <input type="text" name="<?php $this->get_field_name('name'); ?>"> ...


0

I haven't tested this but you could try add_action('pre_get_posts', callback); function callback( &$query ) { if ( is_author() ) { $query->set('author', get_the_author_meta('ID') ); } }


3

It's a bit unwieldy to just grab all posts by an author and filter through them to only return a category list. If you wish to use the default widgets in the sidebar and have them filtered by the author only on the author template then I'd suggest using the following approach. First, filter the tag and category widget queries for categories and tags. ...


1

There is no built in way to do this, and I don't know that it's been tried before. That being said, the tools are all there, you have to put them together. You can get the current User ID with $userid = wp_get_current_user() You can then get all posts by a user with $posts = WP_Query('author='.$userid) Then loop through all posts by the author, and append ...


2

To quote the Codex The return value should be used to determine whether to display a static sidebar. This ensures that your theme will look good even when the Widgets plug-in is not active. So essentially you can use is to display other content if the user has not activated any widgets in the sidebar.


0

I recently wrote an article about wordpress select boxes on the backend, it might help some of you: http://wp-dreams.com/wordpress-widget-select-box/


0

You're almost there, except each widget's settings are stored separately from the sidebars_widgets option, which just stores widget "instances". Try out the following function - you'll still need to use register_sidebar, but it eases the pain for then pre-registering widgets on those sidebars. What it also does is ensure that any existing widgets & ...



Top 50 recent answers are included