Gravity Forms plugin: How to use “gform_editor_js” action hook? [closed]

You can either place the code snippet in the theme functions.php file or in a custom functionality plugin: http://justintadlock.com/archives/2011/02/02/creating-a-custom-functions-plugin-for-end-users Edit: To enqueue custom scripts on the edit page you should use admin_enqueue_scripts e.g. add_action( ‘admin_enqueue_scripts’, ‘my_jquery_function’ ); function my_jquery_function() { if ( rgget( ‘page’ ) != ‘gf_edit_forms’ ) return; wp_enqueue_script(‘mytest1’, get_stylesheet_directory_uri() . ‘/assets/javascripts/mytest1.js’); wp_enqueue_script(‘mytest2’, get_stylesheet_directory_uri() … Read more

WordPress capabilities and restricted categories access

I think best hook should be ‘template_redirect’, when this hook is fired main query is already set, so you can look at queried object and if the user has no required capability you can redirect request somewhere: add_action( ‘template_redirect’, function() { if ( ( is_category( ‘special-category’ ) || is_singular() && has_category( ‘special-category’, get_queried_object() ) ) … Read more

How to change home or site url using action hooks or filter?

Ok. Then you can use template_redirect hook and wp_is_mobile() conditional tag. wp_is_mobile() will work on device only. If you resize the window then it will not work. Now you can try this kind of code in your functions.php file add_action(‘template_redirect’, ‘redirecting_to_mobile_site’); function redirecting_to_mobile_site(){ if( wp_is_mobile() ){ wp_redirect( ‘http://m.example.com’, 301 ); exit; } }

Add custom message to the plugins page of WordPress

Thanks to @rilwis. get_current_screen() returns a page object, from which I can check its id, which I imagine is unique! function dont_update_plugins() { $screen = get_current_screen(); if($screen->id == “plugins”):?> <div class=”updated”> <h3><?php _e( ‘Please do not update plugins!’, ‘my-text-domain’ ); ?></h3> </div> <?php endif; } add_action( ‘admin_notices’, ‘dont_update_plugins’ );

Any hook for pre-plugin-update -either bulk or single plugin update

Here are two untested ideas: Idea #1: If you want to hook before an instance of the Plugin_Upgrader class is created with: $upgrader = new Plugin_Upgrader( … ) where the upgrades are activated with: $upgrader->upgrade($plugin); // for a single plugin upgrade $upgrader->bulk_upgrade( $plugins ); // for bulk plugins upgrades then you could try: /** * … Read more

Get post or page id early

For mee it seems that the template_redirect hook worked. Thanks to Pieter Goosen. Heres a solution that should work on earlier hooks: function gdymc_object_exists( $object_id ) { return ( get_the_title( $object_id ) ) ? true : false; } function gdymc_objectID() { if( is_numeric( $_GET[‘page_id’] ) ): $object_id = $_GET[‘page_id’]; elseif( is_numeric( $_GET[‘p’] ) ): $object_id … Read more

Hook for when a page template is changed

If you want to toggle the editor “on the fly”, you’ll need to revert to a pure JavaScript solution, and only ever “visually” hide it (as opposed to removing it server-side): function wpse_189693_hide_on_template_toggle() { $screen = get_current_screen(); if ( $screen && $screen->id === ‘page’ ) : ?> <script> jQuery( “#page_template” ).change( function() { jQuery( “#postdivrich” … Read more