Create a Page via plugin

You can create the page via wp_insert_post( $post, $wp_error );. The array $post contains the data for your page, with the full documentation here. Be sure to receive the ID from your inserted page/post. You can Add the page at the activation of your plugin, but please check first if the option for the page … Read more

Tips for targeting widget dragable for WP Pointer on widgets.php page

Since the Feature Me widget in the Available Widgets list, is wrapped into something like this: <div id=”widget-5_feature_me-__i__”>…</div> I then wonder if the following would work (untested): ‘target’ => “div[id$=’_feature_me-__i__’]”, to target all div elements with id’s that end with _feature_me-__i__. I think there should only be a single match, at most, if this works.

allow user to select pages from dropdown in my plugin

Change your code to this register_setting( ‘rex_plug_options’, ‘rex_plug_options’, ‘rex_plug_settings_validate’ ); add_settings_field(‘rex_plugbox_text_exit_pop_selected_pages’, ‘Select Pages’, ‘rex_plugbox_text_exit_pop_selected_pages’, ‘rex_plug_box’, ‘rex_plug_main_box’); //with selectbox you cannot select multiple pages. If you need that try checkbox function rex_plugbox_text_exit_pop_selected_pages(){ global $rex_plug_options; if(!isset($rex_plug_options[“rex_plugbox_text_exit_pop_selected_pages”])) { $rex_plug_options[“rex_plugbox_text_exit_pop_selected_pages”] = “”; } ?> <select id=”rex_plugbox_text_exit_pop_selected_pages” name=”rex_plug_options[rex_plugbox_text_exit_pop_selected_pages]”> <?php if( $pages = get_pages() ){ foreach( $pages as $page ){ echo … Read more

Allow Facebook to preview posts before published

Create a new plugin with the following code: class Facebook_Peeker { private static $facebook_bots = [ ‘facebookexternalhit/1.1 (+https://www.facebook.com/externalhit_uatext.php)’, ‘facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php)’ ]; private $original_posts; public function make_scheduled_post_public() { add_filter( ‘posts_results’, [ &$this, ‘peek_into_private’ ], null, 2 ); } public function peek_into_private( $posts, &$query ) { if ( sizeof( $posts ) != 1 ) { return $posts; … Read more

How Can A Plugin Hook Itself To the End of Every Excerpt?

From the codex there are a couple of possible filters for you to try: get_the_excerpt the_excerpt – look at @Mayeenul’s link for usage suggestions Personally I would try the first one with something like: function fileterExcerpt($excerpt){ if(has_excerpt()){ $excerpt .= “Some extra text”; } return $excerpt; } add_filter( ‘get_the_excerpt’, ‘filterExcerpt’ ); Hope this helps.

Only execute jQuery function(on document ready) on the page has shortcode from plugin [duplicate]

You can wp_enqueue_script in your shourtcode. Here are the code I fixed. Register your JS file function wh_enqueue() { wp_register_script( ‘wh-ajax-app’, WH_PATH . ‘/js/write-here-ajax.js’, array(‘jquery’), ‘1.0.0’, true ); } add_action( ‘wp_enqueue_scripts’, ‘wh_enqueue’ ); and enqueue in your shortcode function function ajax_write_here(){ wp_enqueue_script( ‘wh-ajax-app’ ); // Enqueue your script here $output=”<div id=”write_here_ajax_wrap”></div>”; return $output; } add_shortcode(‘write-here-ajax’, … Read more