<?php
/**
* Display the actual Widget
*
* @param Array $args
* @param Array $instance
*/
public function widget($args, $instance){
…
$wcss = apply_filters( 'my-filter-name', $wcss );
…
}
?>
To create your own filter hook just use the function “apply_filters” then
as you mentioned add a function in your constructor i.e.
function __constructor()
{
…
add_filter( 'my-filter-name', array( &$this, 'my_function_name' );
…
}
Be sure your function returns something
function my_function_name( $css )
{
// Do whatever you want
return $css;
}
Related Posts:
- Remove Actions/Filters added via Anonymous Functions
- How to influence the information displayed on widget inside wp-admin
- How to restrict actions and filters “properly” by conditions
- Convert hyphen to underscore in permalinks
- Programmatically Add Font-Awesome Icons to Category Widget
- How to update feed only 2-3 times a week (for Feedburner email)?
- How would go about if I just want a temporary function?
- Accepted arguments value in hook functions
- Which action hook to use for function?
- Modify a function without editing template
- How do I add Bootstrap and LESS to my migrated WordPress site?
- Passing values from a widget to a function within a plugin
- Replace a menu with widget or a custom template file programmatically
- Override the WordPress core function wp_referer_field
- login_headertitle is deprecated since version 5.2.0
- Insert Content Before div#main from the functions.php File
- New checkbox in custom widget isn’t saving data
- Save_post – Warning: Cannot modify header information
- post value to function with Ajax and jQuery
- How Do I Unhook This Parent Theme Function?
- Which method is more correct for removing WooCommerce Extensions menu item?
- previous_post_link inside of a function?
- Settings in functions.php used by a plugin
- disable a specefic sidebar when user is log out
- Remove Actions/Filters added via Anonymous Functions
- How to add_filter html template to middle of content
- AMP – Change rel=”canonical” from functions.php [closed]
- (Woocommerce) Order by price when entering specific category
- Filter an WordPress Function in (general-template.php)
- Scripts not loading when using the wp_enqueue_scripts action
- Can’t Write Custom Widget Code In One ECHO
- Redefine function arguments before rendering
- Is there a way to prevent a function/method from being called outside a specific hook?
- How to edit classes in body tag?
- Auto-Tweet if Type is ‘Status’ using OAuth
- Missing argument for the function
- problem loading stylesheets to wp_head dynamically
- Filter nav menu items HTML tags and wrap inner text with span
- current_user_can comma list vs OR (||) list
- Call to undefined function is_home() or any conditional tags
- Possible to hook into Media Library preview File column and use a custom image?
- How can I add a class to a nav li depending on URL?
- Modify gform_other_choice_value for specific form and specific field in Gravity Forms
- Adding code before post title with the_title produces weird results
- Add back in child theme what the parent theme removed with remove_action
- Combine embed_oembed_html and oembed_result
- Set “woocommerce_is_purchasable” to false for specific “$product->is_stock_status”
- How to display the_archive_title() and the_archive_description() – “weird” interaction
- Filter to wp_list_authors
- How to add custom li item to wordpress menu
- How to properly refresh page after form action?
- Init action and refresh page after form action
- 400 Bad Request – JavaScript App calling Custom wp-json endpoint
- Native gallery custom html output
- Why is it so hard to add a class to the tag in the sidebar widget?
- The correct way to add a JavaScript in the functions.php [closed]
- The_content and Preg_replace in loaded Iframe [closed]
- Passing user enetered value in widget: number of words, for example
- Create a Woocommerce product widget with category filter
- How to edit/replace Parent functions.php function in Child Theme to add “Walker” class
- Add element to widgetpage
- “All posts” in the category widget
- Functions Filter Question [closed]
- Register_Sidebar overwriting itself and doesn’t exist in global $wp_registered_sidebars;
- Changing where my author box is printed
- Is it possible to use add_filter in an included file in the child theme’s functions.php?
- Add Adsense code between job listings – wp job manager plugin
- Problem with images URL after filter applying
- remove_action not working, even after changing priority [duplicate]
- remove/hide wp-editor
- Use add_action within template
- widgets not working
- Problem in using Customizer
- Problem with custom function when I go back with the browser
- Replace header image on all other pages but home – URL issue
- How to echo Widget Title in Custom Frontend-Template Box
- Add a class to post if it has been recently updated
- Replace admin header logo with an image
- the_widget() inside functions.php
- search form leads to 404
- How to conditionally add a widget via a hook in functions.php
- Creating a custom wordpress widget and stopping js from running twice(once in active widget once in widget selector)?
- How do I find the code executed when wp_head() is called?
- how to add_filter to non hook function
- How Do I include/Import a Custom Widget from the Parent theme into My Child Theme?
- template_redirect action only firing if logged in
- Changing the text of Upload/Insert on Posts and Pages Screen
- Adding tables to dashboard pages programmatically?
- Any adverse effects of adding apply_filters to a function?
- Conditional custom menu?
- Add a custom function to widget code
- Get URLs for AJAX Filter Checkboxes WordPress
- Include widget file in functions.php of child theme
- How to use wp_enqueue_script properly?
- how can I add filter in specfic field in my website?
- How to display an image before title text in menu items
- Adding custom social icons to the social media icon block in the Gutenberg editor?
- Using get_terms for custom taxonomy in functions.php
- Customizing the wp_video_shortcode output with add_filter
- Enable accessibility mode in widget as default