Tag Info

New answers tagged

0

It seems that you are executing updateTheme() in every page load. To execute tasks only on activation you should hooke the updateTheme() function to the register_activation_hook action hook: register_activation_hook( __FILE__, 'activation_callback' ); function activation_callback() { //The code inside this function is executed only on plugin activation ...


1

Couple things I'd try: I've seen weird behavior with plugins in general when WP isn't given enough memory. You might want to up PHP and WordPress' memory limit and see if you still get that weird behavior. WP Cron only runs on a page load so between 4:05 and 4:07 (or whenever you're getting the weird behavior), check your server's access and error logs and ...


0

We can add https in very simple way.... No need to had code all these in any hook.... Log in to wordpress admin Go to Settings > General Find WordPress Address (URL) and Replace HTTP with HTTPS Find Site Address (URL) and Replace HTTP with HTTPS Click Save Changes Edit .htaccess file and add bellow code RewriteEngine On RewriteCond %{HTTPS} off [OR] ...


0

The correct way is to use capabilities, for example i have added one called "my_plugin" and check into the client role, so the client will see the menu with my_plugin capabilitie...for example: add_menu_page('Manage Clients', 'Manage Clients', 'my_plugin', 'manage-clients', 'clients_display_page'); So then you go to Users->Roles, edit your role and check ...


0

The correct way to automatically mark a post as private is to do it with the wp_insert_post_data filter. It's very straightforward: add_filter('wp_insert_post_data', 'mark_post_private'); function mark_post_private($data) { if($data['post_type'] == 'your_post_type_goes_here') { $data['post_status'] = 'private'; } return $data; }


0

This worked: "Error: Options Page Not Found" on Settings Page Submission for an OOP Plugin I'd like to understand why register_setting isn't properly adding the property to the whitelisted list to begin with though.


0

Well, that was sutpid of me not to have seen this, but I just have to follow the tutorial and not use get_template_parts()! Moving on.


1

Color schemes are registered globally within $_wp_admin_css_colors (see wp-includes/general-template.php for reference). You can return the colors for the current user depending on get_user_meta() for a specific settings page like this: global $pagenow; if ( $pagenow == 'options-permalink.php' ) : add_action( 'admin_notices', ...


0

You can style a link as a button with the button css class: <a href="#" class="button">I am a button</a> You can modify a button with the primary styling by adding button-primary: <a href="#" class="button button-primary">I am the primary button</a>


1

Thanks to diggy from StackOverflow I've foudn that in the WordPress cycle, the file vars.php (containing my needed functions) is included after muplugins_loaded executes. Including wp_is_mobile() and current_user_can() in wrapper functions fixed my problem. CORRECT function my_epic_function() { if(current_user_can( 'edit_posts' )) { ...


1

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 ...


0

Here's a workaround you can put in a plugin or your theme's functions.php file. So far no problems. /* * Workaround Bug 30123 * Affects WP 4.0+, should be fixed in WP 4.1 * https://core.trac.wordpress.org/ticket/30123 */ function bugfix30123__action__admin_init() { if ( isset( $_GET['attachment-filter'] ) && is_string( $_GET['attachment-filter'] ...


2

There is nothing technically wrong with that, but backslashes are hard to type on some keyboard layouts. On a German keyboard for example, you have to hit the right AltGr key plus \ at the same time. This is not easy to type (and one of the reasons why I use an English keyboard). Use dots, colons or underscores to namespace your hooks. They are not bound ...


0

The Problem This turned out to be a common case of needing to use stripslashes();. How did I figure this out? I logged into phpMyAdmin, navigated to the options table, found my option name, and edited it. Here's what I discovered... s:11:"description";s:90:"<span style=\"text-decoration: underline;\">This is supposed to be underlined ...


1

Try this code. Create a file like "my_db.php" and paste this code: global $table_version; $table_version = "1.0"; function func_table_contactus(){ creat_table_contactus(); } function creat_table_contactus(){ global $wpdb; global $table_version; $table_contactus = $wpdb->prefix."contactus"; $slider_ver = ...


3

Your dot and quote notation is funky. Try this: if($wpdb->get_var("SHOW TABLES LIKE '$table_name'" ) != $table_name){ $sql= "CREATE TABLE $table_name ( id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY, firstname VARCHAR(30) NOT NULL, lastname VARCHAR(30) NOT NULL, email VARCHAR(50), reg_date ...


1

That's why the last line of the get_admin_url contains the line: return apply_filters( 'admin_url', $url, $path, $blog_id ); Any valid modification of the admin URL will be via that filter, so get_admin_url is the correct function to use in all cases.


0

I'm using something like this foreach( $wp_scripts->queue as $handle ) : $obj = $wp_scripts->registered [$handle]; $filename = $obj->src;


1

WordPress have on default no relationship possibilities for the same objects, like custom post type. But you can create a custom table or use the meta data on each post to create a relationship. Ready to use Also it give usable ready solutions: Post2Post plugin ACF Relationship Field For a custom solution about meta fields: You find in this answer ...


0

I finally included the external PHP file in a Wordpress function in my plugin PHP file. function get_conf_function(){ require_once(dirname(__FILE__) ."/parts/conf.php"); } Now, I can access to wp functions when I call that function (with Ajax or not).


0

public function my_plugin_action_links( $links ) { $mylinks[] = '<a href="'. get_admin_url(null, 'admin.php?page=settings') .'">'.__('Settings', 'woocommerce').'</a>'; return $mylinks + $links; } Adding return $mylinks + $links;, it orders the array


0

This might not solve your problem directly, but I would like to mention that if you want to avoid WordPress.org you can host your plugin on GitHub (or Bitbucket). There is a updater plugin for that and on Tut+ is a good Tutorial for that: Distributing Your Plugins in GitHub with Automatic Updates


0

You can with filter. On your plugin : $value = 0; $value = apply_filter('get_value_from_function', $value); Then on functions.php add_filter('get_value_from_function', 'my_special_value_treatment', 10, 1); function my_special_value_treatment ($value){ return 1; }


0

You'll have to use get- and add_option inside a register_activation_hook. <?php register_activation_hook(__FILE__,'save_activation_timestamp'); function save_activation_timestamp() { add_option("myplugin_activation_timestamp",mktime()); } ?> You can find an entire tutorial on that at CodeYoghurt. It even mentions your case as an example.


-2

Zend's Z-Ray has a theme profiler. Also useful for seeing SQL queries.


0

Got it. This post demonstrates what I need.



Top 50 recent answers are included