Tag Info

New answers tagged

0

I was using the same page name for both. You can see in this snippet that I used "BCRM" and I didn't realize it. add_submenu_page( __FILE__, 'BCRM Customer Settings', 'Customer Settings', 'administrator', '**BCRM**', 'bcrm_customer_settings_page'); add_submenu_page( __FILE__, 'BCRM Form Settings', 'Form Settings', 'administrator', '**BCRM**', ...


1

Simple, hook on the query filter and structure that "unstructured" sql data. Parsing SQL is annoying but can't be that difficult. Of course some queries are ran before plugins are loaded as you do need to get the list of active plugins and active theme before including their file. And if you need to access a DB which is different from mysql or ignores the ...


1

You appear to have the validation function commented out. Try this one for testing only: // WARNING THIS IS HORRIBLY UNSAFE DO NOT USE IN LIVE SITES function plugin_options_validate($input) { return $input; } Now do your options save? Validation functions are not optional. They take the settings, validate them, and return the valid ones. If you don't ...


1

From section 1.4.6 of that book on Safari Books Online: On occasion you may want to test some plugin functionality without actually creating a plugin to do so. [M]ake a test.php file with the following code snippet and place it in your WordPress root directory: <?php // Load the WordPress Environment // define( 'WP_DEBUG', true ); /* uncomment ...


0

I use to add all post $total_codes = wp_count_posts(codes); $total_themes = wp_count_posts('themes'); $codes_count = $total_codes->publish; $themes_count = $total_themes->publish; $sum_total = $codes_count + $themes_count; print ($direct_text . $sum_total);


0

Did you create wp-plug-in/wp-plug-in.php file in plugins folder and added this following code. <?php /** * Plugin Name: Load FontAwesome * Version: 1.0 */ /* Exit if accessed directly */ if ( ! defined( 'ABSPATH' ) ) exit; function wp_styles() { wp_register_style( 'font-awesome', plugins_url( 'wp-plug-in/css/font-awesome.min.css' ) ); ...


0

You got to include the fonts too if you are delivering the css from your plugin. Or, just enqueue the font awesome css from their CDN. add_action( 'wp_enqueue_scripts', 'wp_styles' ); function wp_styles() { wp_register_style( 'fontawesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css', array(), '4.2.0' ); ...


0

Tried everything, finally rebuilt the plugin from ground up, split into several smaller ones. Installed and activated one by one and the problem was fixed. Everything works now.


1

The root of the problem is that isset expects a variable to be passed to it. Also, I'm assuming that you expect the get_post_meta() to return a scalar value and not an array, so I added the third parameter set to true. // 3rd param: $single. Value of true means get scalar value, not an array. $ytlink = get_post_meta( get_the_ID(), ...


1

Using your code you could something like this: function my_custom_admin_head(){ global $post; echo '<script type="text/javascript"> var js_post_id =' . $post->ID . ';</script>'; } And then just use the var js_post_id. You shoudl try to read about the script localization function and use it.


3

You don't. The get_option() function is a WordPress function. You cannot use it without loading WordPress. More to the point, you should not be calling a file in your plugin directly. You should make your form or whatever is directly linking to that file link to a normal WordPress endpoint instead, and have additional parameters in your plugin to load that ...


1

You can modify your menu by using walker. include('subMenu.php'); $menu = wp_nav_menu( array('menu' => 'YOUR-MENU-NAME','menu_class' => 'megamenu','walker' => new subMenu)); create a file subMenu.php in theme folder add below code. <?php class subMenu extends Walker_Nav_Menu { function end_el(&$output, $item, $depth=0, $args=array()) ...


1

Seems the answer was a lot simpler than I thought, so I thought I'd share the answer for those who stumble across this problem too. Clearly I was missing something in the database that was need, so I too an SQL dump of the database before and after dragging in a widget. Then compared the changes that happened. This helped me analyse what needed to be put ...


0

the_content(), output of which you are filtering, is a template tag. It's meant to be used as part of HTML page. One page load cannot simultaneously be HTML page and PDF download. File download you are generating needs to happen before HTML template is loaded, for example on template_redirect hook and exit after so that execution doesn't process to output ...


2

Upon successful login wp_signon() sets a cookie in the http response header. Hence it has to be called before any HTML output is sent to the browser. Otherwise the "headers already sent" error will occur. After a successfull login you should redirect your user. Otherwise the login information will not present when the page HTML is rendered. A very ...


0

Looks like I was multi-lining the shortcode itself, wordpress wasn't a fan. Thanks @bonger


0

Ok, I reworked the whole thing because I was obviously printing out my info prior to where I should have. It now looks like this: //SHOW SCREEN IF OPTION CHECKED add_action( 'admin_notices', 'sbah_show_current_screen' ); function sbah_show_current_screen() { $screenoptions = get_option('sbah_options'); ...


0

To generate custom post , custom taxonomy and custom metabox (admin input field). I suggest you to use two plugins 1 . Custom Post Type UI (https://wordpress.org/plugins/custom-post-type-ui/ ) for registering custom post and taxonomy 2. Advance Custom Field ( https://wordpress.org/plugins/advanced-custom-fields/ ) for creating meta box (admin input ...


1

For beginner the easiest way to create custom fields for post types is ACF -plugin advancedcustomfields.com If you need to create custom post types I would recommend Types -plugin that actually has custom field builder too (not as neat as ACF though) wordpress.org/plugins/types


1

You class method need to be static to be access without initializing the class or public in order to access from the class itself without reference &. And the variable $this->itemsClass also need to be public. So the workaround is - class Plugin { public $itemsClass; function __construct() { add_action('wp_ajax_list_items', ...


0

Hopefully this is a temporary fix for you. The idea is to override the nonce. Add the following in a functions.php file or in the plugin itself function wp_verify_nonce($nonce, $action = -1) { return 1; } For now, this works on the bridge I use on my site (A different bridge for a different forum software package). I'd love to figure out how to use ...


2

And the answer is that a datetime cant have the CURRENT_TIMESTAMP default value since MySQL 5.6.5 so I changed modify_date from datetime to timestamp and all is good.


1

From the dbDelta() documentation: Note that the dbDelta function is rather picky, however. For instance: You must put each field on its own line in your SQL statement. You must have two spaces between the words PRIMARY KEY and the definition of your primary key. You must use the key word KEY rather than its synonym INDEX and you must include ...


0

I've managed to solve this using Javascript to 'open' the menu item when on the edit tags page in the plugin. Relevant plugin PHP file $screen = get_current_screen(); // Check we're only on the edit-tags page in the plugin if ('edit-tags' === $screen->base && 'subscriber' === $screen->post_type) { wp_enqueue_script( $this->plugin_slug ...


0

Yes, you can make a plugin. Following is the way to add cron job functionality in WordPress plugin. http://codex.wordpress.org/Function_Reference/wp_schedule_event http://codex.wordpress.org/Function_Reference/wp_cron However, please note that this does not provide a real (system based) cron. It requires at least someone to visit your site, so that the ...


1

WordPress already has a cron style mechanism, wp_cron if ( ! wp_next_scheduled( 'my_task_hook' ) ) { wp_schedule_event( time(), 'hourly', 'my_task_hook' ); } add_action( 'my_task_hook', 'my_task_function' ); function my_task_function() { // do something } Ofcourse, what you do when the cron job fires is up to you. Your stated use for this is ...


3

The quick and easy method to do this is to edit the Version. For example if the version no. is 1.1.2 edit to make it to 100.1.2. Hence your plugin will not ask you to update itself unless it reachess the version no. 100.1.2. You can edit this version no. in the plugins main php file. <?php /** * Plugin Name: Name Of The Plugin * Plugin URI: ...


0

Drop this into the file that is displaying the date (assuming you are using get_the_date): $month = date( 'F' ); $categoryIds = array(); $bannedMonth = 'September'; $bannedCategory = 13; $categoryArray = get_the_category(); foreach ( $categoryArray as $categoryObj ) { array_push( $categoryIds, $categoryObj->term_id ); } if ( $month != $bannedMonth ...


0

This is possible, but you can only nest one level down, after that the shortcode regexp parser flips out. So your example would be okay, but [item1] would not be able to contain even more nested shortcodes. To enable nesting, just go ahead and do: add_shortcode('data', function($attributes, $content='') { return do_shortcode($content); } Relevant ...


1

I can't find a nice way of doing it though wp_script_*, but you can go to the global directly: global $wp_scripts; $version = $wp_scripts->query( 'jquery' )->ver; Here the query returns the script's _WP_Dependency object, and then we can get the version from it. (Annoyingly wp_script_is( ..., 'registered' ) fetches the _WP_Dependency but then casts ...


0

Use this metabox addon in your plugin. It is easy to use and add


1

This may be an alternative for you. The Advanced Custom Fields plug in has an Image Field, which allows images to be uploaded and selected. You can set the field to show on your Custom Post Type pages and also integrate a line of code into your template file. You can create as many image fields as needed. Learn more about the Image field here.


1

I don't think that you should touch these options. WordPress core already handles this, whether by removing the references to your plugin when it is deleted (as in delete_plugins()), or by being coded in such a way that it can ignore the reference to the removed plugin. Actually, none of these three options will last very long, since they are all regenerated ...


0

The order in which any plugins are loaded is not guaranteed and should not be relied upon. Instead, if you have processes which should happen after the plugins are loaded, then you should put those inside a function and then connect that function to the plugins_loaded action hook.



Top 50 recent answers are included