Tag Info

New answers tagged

1

global $langOK; add_action( 'plugins_loaded', 'myplugin_load_textdomain' ); function myplugin_load_textdomain() { global $langOK; $langOK = ( load_plugin_textdomain( 'my-plugin', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' ) ) ? TRUE : FALSE; } Later you can check the value of $langOK ( TRUE = success, FALSE = failure ).


0

I finally figured out a solution using query vars to pass the status message to the next page so that it can be used in post_updated_messages. Here's a simplified version of what I did, with all the function names changed for simplicity's sake to focus on the problem at hand; First, added the value I needed to the $_POST var; function ...


1

There is error in sql query. You have defined time as datetime and default value mentioned in current_timestamp. Define time as timestamp. Also specify length of email and page fields. Corrected query: $sql = "CREATE TABLE " . $table_name . " ( id INT NOT NULL AUTO_INCREMENT, time TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL, //Change datetime to ...


2

I was searching for the same answer this morning for my plugin AnsPress. So I sneak into WordPress plugin wp-admin/includes/plugin.php and got an idea. WordPress check for fatal error while activating plugin, so simplest solution will be trigger a fatal error and this will prevent WordPress to activate the plugin. In my below code I check if plugin files ...


0

I believe you can get the same result what you are looking for with filter hook post_updated_messages. You just need the post id for the confirmation thing that you are doing which you can do over here as well using $_GET['post'] which contains your post id. Here is function which will do the thing. function your_modified_message( $messages ){ ...


1

The reason is that you can register native PHP functions as callbacks. Passing more parameters to them then they expect will raise a warning. Imagine a filter that can pass 6 parameters and trim() as callback. PHP would now raise an error: Warning: Wrong parameter count for trim() in … Some custom callbacks might also change their behavior depending ...


1

I try this code and it solve my problem if ( is_child_theme() === false ) { // files moved } else { // do nothing } Thankx to @birgire


0

You could try the following: add_action( 'switch_theme', function( $new_name, $new_theme ) { if( is_a( $new_theme->parent(), '\WP_Theme' ) ) { // Child theme was activated } else { // Parent theme was activated } }, 10, 2 ); to see if the theme you just activated is a child theme or not.


0

I have changed the do_action() for a apply_filter(). This worked as follows: // Filter save settings $settings = apply_filters( 'gtp_theme_settings_tab_save', $settings, $tab, $_POST ); $updated = update_option( 'gtp_theme_settings', $settings ); And then my add_filter in plugin file looks like: function ac_theme_settings_tab_save( $settings, $tab, ...


0

You will have to create a settings page on which you will have to register your settings. Unfortunately this is no easy task, but it has been very well documented on tutsplus. Once you have implemented the settings api, you can check for the options that have been set with your settings page. Depending on the values of the options that have been specified, ...


0

By enququing an JS file we can do like this: <img src="#" id="img-src"> <a href="#" id="img-upload">Add Image</a> Content of JS file jQuery(document).ready(function(e){ e.preventDefault(); jQeury('#img-upload').click(function(){ var upload = wp.media({ title:'Choose Image', //Title for Media Box ...


0

The answer is to specify all the args on the add_filter() call, and then you can have both the array of posts and the query sent to the callback. add_filter( 'posts_results', 'do_stuff', 10, 2 );


0

Various possibilities. If fixing a bug, I'll sometimes actually make a patch and send it to the Plugin author. More than once they've added the patch and said thanks. Beyond that, if you really need to hack a plugin, you should also change the folder and header info so that the auto-update doesn't recognize it. Of course you'll not get new updates. ...


0

So to answear my own question after much googeling: In the args array I commented out the option for show_in_menu, so that custom post type creates the menu itself. Then I didn't add the admin menu, but just the submenu (the hook still remains). add_action('admin_menu','bsp_plugin_menu'); And the first parameter is the one that shows it in the menu ...


1

The main issue I was having is that when an ajax request hits not all hooks are being loaded. I used this code: $return = array(); foreach( $GLOBALS['wp_actions'] as $action => $count ) { $return["message"] .= $action . ", "; } wp_send_json($return); This showed me the hooks that were running before and I got it to work. I think removing ajax ...


0

I see a few things missing in your snippet/code. Each field (your location ones) need to include priority: 'priority' => 19, You defined 'type' as 'location' but did not define that field type. The repeated files in resume manager where you based this code on defines template files for education, experience etc. To define your own filter on ...


0

Here's the JS I use to replace checkboxes for radio buttons. function checktoradio(){ echo '<script type="text/javascript">jQuery("#categorychecklist-pop input, #categorychecklist input, .cat-checklist input").each(function(){this.type="radio"});</script>'; } add_action('admin_footer', 'checktoradio'); This would also work for custom ...


2

There is always a timeout, be it TCP or the PHP execution time ( unless you configure your server in a weird way, PHP will kill long running tasks ). If you need to do a lot of work you should: Break it into smaller pieces Plugins like regen thumbnails retrieve a list of items to do work on, then go through the list in small fast batches keeping track of ...


2

You have the following methods of the $wpdb object: $wpdb->flush() that contains a call to mysqli_free_result() or mysql_free_result() if not supported. $wpdb->check_connection() that contains a call to mysqli_ping() or mysql_ping() if not supported. You can of course use all your PHP functions in WordPress. Here's an example based on the \wpdb ...


5

You don't, for the same reason you don't modify WordPress Core, you extend it or use hooks and filters to modify its behaviour. So when extending or changing plugins you have 2 options: Forking You've been creating forks of a plugin so far, but it's important to change the name when this happens so your new plugin isn't overwritten. You'll need to ...


1

There is no such child folder, but depending on the type of change, you can write a new plugin to override the code. If it's Revolution Slider, be sure you're reading all the documentation to be sure you actually need to be doing the edits in the first place. Most things you would "need" to change might actually be settings.


0

Check the codex - wpdb::prepare expects the first argument to be a sprintf syntax string, followed by the arguments to be injected (again, just like sprintf): echo $wpdb->prepare( '%s', $fetch_row );


0

We can different types of fields for 'Resume Manager' & save it. We can achieve this via filter, as follows, //code to add custom field for Resume Manager on front end add_filter( 'submit_resume_form_fields', 'wdm_customize_resume_fields' ); function wdm_customize_resume_fields($fields) { $fields['resume_fields']['candidate_address'] = array( ...


0

Try this way: add_action( 'save_post', 'myFunc'); function myFunc(){ if ($post->post_type == 'cpt' ) { // do action here } OR add_action( 'save_post', 'myFunc'); function myFunc(){ if ( 'cpt' == get_post_type() ) { // do action here }


0

As @Pieter said, you can use transition_post_status: function wpse_187997_job_status( $new_status, $old_status, $post ) { if ( $post->post_type === 'job' && $new_status !== $old_status ) { // Post type "job" and status has changed } } add_action( 'transition_post_status', 'wpse_187997_job_status', 10, 3 );


0

You can use the template tag is_feed() to determine if the current request is for a feed: if ( is_feed() ) { // It's a feed! } else { // Regular 'ol WordPress } Note you'll need to use the function after the request has been parsed (i.e. on or after the parse_query hook).


0

This is what I´ve done so far, I won't mark as correct answer yet in case there is a better approach that Im not aware. add_action('wp_enqueue_scripts',array( $this, 'remove_all_actions'), 99); public function remove_all_actions(){ if( 'custom-template.php' != get_page_template_slug( get_queried_object_id() )) return; global ...


1

Any reason you've chosen Docker over other virtual solutions like Vagrant? I prefer to use Bedrock, which is a modern take on the Wordpress stack using Vagrant for managing environments (from the guys that made the Roots aka Sage starter theme for Wordpress). https://roots.io/bedrock/


0

It seems a little odd to only offer the admin bar for a page, but the easiest solution I can think of would be to use conditional functions to deregister scripts/styles and create custom template files for this specific page. Unfortunately, you'll have to figure out all the styles/scripts that are loaded add_action('init', 'remove_all_the_things'); ...


1

Ok i done by my own. I delete all above code and write this code. It works perfectly for me Code: function template_chooser($template){ global $wp_query; $plugindir = dirname(__FILE__); $post_type = get_query_var('post_type'); if( $post_type == 'product' ){ return $plugindir . '/themefiles/single-product.php'; } if ...


1

I'm going to post a partial answer to start the discussion in the hope of getting some helpful comments to fill in the blanks or alternative answers... Step 1: Install and Set Up boot2docker Docker only runs on Linux. So in order to use Docker on our Mac, we need to install boot2docker, which will run Docker in a Linux VM. You can install boot2docker using ...


0

You can insert something like this: <p class="description">This is my description</p> The description class is a built in WP class that will produce the style of text you pointed out in your image.


0

Have you looked at 'wocker'? It uses docker within Vagrant.


3

I think you're over thinking things. I'd simply create a new Custom Post in the plugin. That will come with it's own backend automatically. You can then create the individual pages based on the Template Hierarchy for both the listings and individual pages. For any additional fields you need, you can either set the meta fields to show on the backend or add ...


0

For your situation, ideal solution would be this plugin: Restrict Categories It allows you to restrict the users to add, view and edit categories. Note: But before installing, make sure you have a backup. The most recent review had a problem of categories getting disappeared.


0

At the end of your function return the output as described in the documentation. return ob_get_clean(); Add the [myshorcode] shortcode to a text widget. By default, widgets are not rendered in text widgets so make sure you add this snippet to your plugin: add_filter('widget_text', 'do_shortcode');


0

Also look at the upgrader_post_install hook. It's at the end of the install_package function, see also the rather bland WP developer page on this hook -- but of course you'll want to run tests yourself to ensure this hook indeed fires when WP core, any plugin, or any theme is upgraded. In general, I'm finding Adam Brown's WP hooks database the most ...


0

Instead of calling the iframe , You can register a widget that will contain all the HTML code.Another way can be outputting the whole HTML code instead of iframe."id" can be controlled in the same manner. Combine all CSS files and JS files and then enqueue them in the same manner.Keep HTML code only between the body part.I am not sure but may be this helps.


0

Use SVN to update the readme.txt file which is located in the /trunk Your current code: === My Auction Creator === Contributors: Suyog Computech Pvt Ltd Update line 2 to insert your wp.org account's username rather than the full name: === My Auction Creator === Contributors: username Refresh the page and you'll see a linked avatar and your name as the ...


1

You will need to login to your account at WordPress.org ... if you have one. If you do not have one you need to register. After that you can edit your profile at https://profiles.wordpress.org/username/ where username is your wordpress.org user name. Sometimes it take a little while for them to get everything updated. Have they approved your plug-in also?


10

I believe what you're referring to is called "Post Types". By default, WordPress has a complete post types you're already familiar with - post ( news / blog ), page ( Pages ), attachment ( Media ), revision ( Page / Post Revisions ). You can read up on the full list of built in post types on The Codex - Post Types. If you want to register a new Custom Post ...


0

These are called custom post types. There are several ways to create new post type, using a plugin or creating yourself. If you prefer using a plugin, try this- https://wordpress.org/plugins/custom-post-type-ui/ If you want to create them yourself without any plugins, you need to add some codes to functions.php file in your theme. This is a simple example: ...


0

The moment you publicly distribute your code, it must be either GPL, or GPL compatible. You can figure this out by looking at the licence, if it forbids anything that the GPL allows, it's incompatible, so the license must be as permissive as the GPL, or even more so There is nothing stopping this business from taking the work you've done for them and ...



Top 50 recent answers are included