Duplicate Widget
A widget that can act as a duplicate of another widget (for synchronized use in another sidebar) Define a widget once, use it in multiple sidebars. This saves you from having to manually configure each copy of the widget and later having to worry about keeping them in sync should you ever need to make any changes. Particularly useful for those who define logic in their themes to conditionally include different versions of a sidebar depending on what template is being shown. Depending on use, it is an alternative to plugins that introduce in-widget logic to determine when widgets should be visible (Widget Logic, Section Widget, Conditional Widgets, etc). Quick overview of what this plugin does: Adds a widget called “Duplicate”. The widget’s only setting is a dropdown listing all active widgets. The selected widget will be the widget duplicated by the duplicate widget. A duplicate widget shows the same title and content as its source widget, even if those values later get changed in the source widget. A widget can be duplicated any number of times and can appear multiple times within the same page. (Yes, even within the same sidebar, though why would you do that?) A duplicate widget will abide by the configuration of the sidebar it is placed in, not the configuration of the sidebar containing the source widget. So it uses ‘before_widget’, ‘after_widget’, ‘before_title’, ‘after_title’ values of its own sidebar. Widgets that are duplicated will have “[D]” prepended to their name in the widget titlebar in the admin to denote they have duplicates. Also, at the bottom of the widget’s configuration form (when the widget is expanded), a short blurb also explains that the widget has duplicate(s) and a count of how many duplicates it has. If a widget is deactivated or deleted, if it has any duplicates, they get deleted as well. The widget id and widget type of the source widget are included as HTML classes in the duplicate widget’s markup. Links: Plugin Homepage | Plugin Directory Page | Author Homepage Filters The plugin exposes four actions for hooking. Typically, customizations utilizing these hooks would be put into your active theme’s functions.php file, or used by another plugin. c2c_before_duplicate_widget (action) The ‘c2c_before_duplicate_widget’ hook allows you to output text, or perform some sort of action, just before the output of the duplicate widget. Arguments: $instance (array) : The settings for the widget instance (namely: title and widget_to_duplicate) $args (array) : The configuration for the widget and sidebar Example: // Output an opening before duplicate widget content add_action( 'c2c_before_duplicate_widget', 'my_c2c_before_duplicate_widget', 10, 2 ); function my_c2c_before_duplicate_widget( $instance, $args ) { echo ' ; } c2c_after_duplicate_widget (action) The ‘c2c_after_duplicate_widget’ hook allows you to output text, or perform some sort of action, just after the output of the duplicate widget. Arguments: $instance (array) : The settings for the widget instance (namely: title and widget_to_duplicate) $args (array) : The configuration for the widget and sidebar Example: // Output an closing after duplicate widget content add_action( 'c2c_after_duplicate_widget', 'my_c2c_after_duplicate_widget', 10, 2 ); function my_c2c_after_duplicate_widget( $instance, $args ) { echo ' ; } c2c_before_duplicate_widget_form (action) The ‘c2c_before_duplicate_widget_form’ hook allows you to output text, or perform some sort of action, just before the output of the duplicate widget’s configuration form (in the WP admin). Arguments: $instance (array) : The settings for the widget instance (namely: title and widget_to_duplicate) Example: // Display a message just before the duplicate widget settings form add_action( 'c2c_before_duplicate_widget_form', 'my_c2c_before_duplicate_widget_form' ); function my_c2c_before_duplicate_widget_form( $instance ) { echo ' Note: this is a note above the widget settings form. '; } c2c_after_duplicate_widget_form (action) The ‘c2c_after_duplicate_widget_form’ hook allows you to output text, or perform some sort of action, just after the output of the duplicate widget’s configuration form (in the WP admin). Arguments: $instance (array) : The settings for the widget instance (namely: title and widget_to_duplicate) Example: // Display a message just after the duplicate widget settings form add_action( 'c2c_after_duplicate_widget_form', 'my_c2c_after_duplicate_widget_form' ); function my_c2c_after_duplicate_widget_form( $instance ) { echo ' Note: this is a note below the widget settings form. '; }
Top keywords
- widget64×8.64%
- duplicate39×5.26%
- duplicate widget28×3.78%
- c2c16×2.16%
- form13×1.75%
- action12×1.62%
- instance12×1.62%
- output10×1.35%
- c2c after duplicate8×1.08%
- c2c before duplicate8×1.08%
- settings8×1.08%
- sidebar8×1.08%
Force Admin Color Scheme
Though it is typically an individually configurable aspect of WordPress, there are times when forcing a single admin color scheme upon all users of a site can be warranted, such as to: Provide a unique backend color scheme for multiple sites used by the same set of users to reinforce the difference between the sites. Clearly denote backend differences between a production and staging/test instance of a site. Especially given that in this situation with the same plugins active and often the same data present, it can be easy to get mixed up about what site you’re actually on. Force a site brand-appropriate color scheme. Crush the expression of individuality under your iron fist. Additionally, the plugin removes the “Admin Color Scheme” profile setting from users who don’t have the capability to set the admin color scheme globally since being able to set its value gives them the false impression that it may actually apply. Links: Plugin Homepage | Plugin Directory Page | GitHub | Author Homepage Hooks The plugin is further customizable via one filter. Typically, code making use of filters should ideally be put into a mu-plugin or site-specific plugin (which is beyond the scope of this readme to explain). c2c_force_admin_color_scheme (filter) The ‘c2c_force_admin_color_scheme’ filter allows you to set or override the forced admin color scheme. Use of the constant (“) takes priority over the filtered value, but the filtered value takes priority over the value set via the admin. Arguments: $color (string): The name of the admin color scheme. If an empty string is returned, then the plugin will behave as if no forced admin color scheme has been defined. Example: /** * Sets a forced admin color scheme based on user. Admins get one color scheme, whereas everyone else gets another. * * @param string $color The current forced admin color scheme. Empty string indicates no forced admin color scheme. * @return string */ function my_c2c_force_admin_color_scheme( $color ) { return current_user_can( 'manage_options' ) ? 'sunrise' : 'coffee'; } add_filter( 'c2c_force_admin_color_scheme', 'my_c2c_force_admin_color_scheme' );
Top keywords
- color20×5.75%
- admin15×4.31%
- color scheme15×4.31%
- scheme15×4.31%