Tag Info

New answers tagged

0

This is always a problem when using a plugin that loads extra css/js files. You could add custom fields to the pages where you want to exclude css and js files (called something like page_exclude_css and _js), with comma separated style and script handlers as it's values. Then you add a function to to the wp_enqueue hooks (at a position like 9999) that ...


0

WordPress doesn't operate with DOM for the purpose of page source generation from templates. Templates are treated and run as PHP source files, producing any and all output. Unless you have control over actual templates your options likely are: Attempting to buffer and rewrite output (rather fragile, more so for publicly released plugin) Adjust markup ...


1

prepare() is used to escape the values for example in the WHERE-statement. Usually it is anticipated the table selection is "hardcoded". If you can't use for example $wpdb->posts or the other "table"-functions, you could whitelist the allowed tables and check if $table_name is on this white list: <?php $allowed_tables = array( $wpdb->prefix . ...


0

You can't get that data on an option already saved by a plugin, but what you can do is monitor add_option, update_option and possibly get_option activity to find out which plugins are using which options with simple backtracing. I put together a little snippet for you: function gimme_your_options( $option_name ) { $blame = 'core'; $debug_backtrace = ...


1

Your best option is likely to copy all the names into your plugin to use for retrieval. Of course, this could change when the plugin is updated. When options are saved in the database using update_option() there's no indication of which plugin they came from that gets stored anywhere. If the options all use a particular prefix though, you could construct a ...


0

I don't think this is possible or a universal function for this exists. Whenever you add an option you do so by adding an option_name and option_value - add_option(). <?php add_option( $option, $value, $deprecated, $autoload ); ?> So whenever plugins add their options to the database, they use that function and usually prefix the option name with ...


0

It's hard to tell what's going on with your enqueue scripts but that's probably the most preferred way. A secondary option would to add it directly to your header.php file: <head> <script src="<?php echo get_template_directory_uri(); ?>/js/html2canvas.js"></script> <script src="<?php echo get_template_directory_uri(); ...


1

As it turns out there's a difference between 127.0.0.1 and localhost. Once I change my requests to: http://localhost/white/check-plugins/plugins/test-plugin.zip and a few other instances of the IP version, the update worked like a charm. Stack Overflow has some good answers on why this could be: What is the difference between 127.0.0.1 and localhost?


0

SOLUTION: register_activation_hook( __FILE__, 'my_activation_func' ); function my_activation_func() { file_put_contents(__DIR__.'/my_loggg.txt', ob_get_contents()); } insert this code in plugin, and after error, view "my_loggg.txt" inside your plugin folder.


0

It is possible to install Composer and then install wp-cli . Under Alternative-Install-Methods it says to use wp-cli/bin/wp.bat, although I didn't like typing that path. After installing in the manner mentioned, I created a wp.bat in my WordPress root along side wp.phar with the following contents: @ECHO OFF php "wp-cli/php/boot-fs.php" %* Seems to work ...


1

Using the delete_user action you can pass in the user_id and use that as a basis to delete the user from your addtiional table. This is, of course, assuming you use the user_id to make a relation between the two table. If not you can use get_userdata() passing in the user_id to get more user information. It would look something like this: function ...


0

If I remember, when a user is logged in using wp-loing.php, it is redirected. So, the correct flow should be: User log in In next page load (when user is redirected), hook on init and check if the user is correctly logged in, if so, start session and populate $_SESSION. Hook on wp_login and wp_logout to destroy session (also in wp_login, if user log in ...


1

Have you tried this plugin? WP Permastructure Adds the ability to configure permalinks for custom post types using rewrite tags like %post_id% and %author%. Download this plugin https://wordpress.org/plugins/wp-permastructure/screenshots/


0

You cannot move a file over HTTP, instead you need to move it using local path. (e.g. /home/content/site/folders/filename.php). normally people upload files to media library. The following code shows how to upload a file from a plugin. if ($_FILES) { foreach ($_FILES as $file => $array) { if ($_FILES[$file]['error'] !== UPLOAD_ERR_OK) { ...


1

The error message you are seeing is normal for that operation. By the time the transition_post_status hook fires, the HTTP page headers is already sent. By simply echoing an error message inside a hook like transition_post_status which was never intended to echo any output to the browser, as you did, you are actually trying to insert your error message into ...


0

The simple answer is, "No". Although admin_enqueue_scripts and wp_enqueue_scripts hooks does exactly the same thing, the do their work in separate places which do not have any reference to the other. wp_enqueue_scripts runs on the public side or front end admin_enqueue_scripts As the name suggests, it runs on the admin side or back end Your script that ...


2

Straight outta the Codex: wp_enqueue_scripts is the proper hook to use when enqueuing items that are meant to appear on the front end. Despite the name, it is used for enqueuing both scripts and styles. So the simple answer to your question is yes, wp_enqueue_scripts is always the correct action for enqueuing scripts AND styles. This is so other ...


0

Awesome! This solved my problem. But then I had another. Many people, like me, keep classes in a folder lower than the plugin file that is instantiating them. So you might have in your plugin file: //assumes some kind of autoloading $vsetup = new vsetup; //where there might be a file called 'classes/vsetup.class.php' Well, this is the way I do it, and the ...


1

You have a few options. If you don't want to disable any plugins, try to use the P3 Profiler plugin to identify the plugin or plugins that are slowing down your site. If you don't want to run experiments on your live website, you should make a copy on a sub-domain (you can use the Duplicator plugin for this), make sure the second website is not accessible ...


1

"[C]an you give me all options that are possible"? (emphasis added) No, because HTML, CSS, JS, PHP, and WordPress are powerful and sophisticated. Below are are some different approaches, however. [Affiliation: I am not affiliated with any plugins or programs listed here.] is_user_logged_in() In WP, the level closest to the code is to use the function ...


1

Is your plugin intended for use by others, or is it only going to be used on servers you control? If the latter, then there might be a few ways to achieve what you want. For instance, the Sync extension. With that, I think you could use a mutex or semaphore to set a flag, which you could then use in your read/write functions. If you already have memcache ...


1

Assuming that you have a Custom Post Type "myaudio": Create a function to render the upload page <?php function brg_upload_audio_page(){ //display uplaod form if (empty($_POST)){ ?> <h2>Upload Audio</h2> <form action="" method="post" enctype="multipart/form-data"> <p>Title of the song</p> ...


0

// First, get associated taxonomies of the post/object. $object_taxonomies = get_object_taxonomies( get_post() ); // Next, get associated terms of the post/object. $object_terms = wp_get_object_terms( get_the_ID(), $object_taxonomies ); $terms = array(); // returned object terms could be WP_Error, so check that first. if( ! is_wp_error($object_terms) ...


2

All Credit to the following post goes to Abid Omar. The full tutorial can be found on Tuts+: A Guide to the WordPress HTTP API: Automatic Plugin Updates View Plugin On Github The gist is to create a new class which will post an external file ( API ) and return plugin to download if it's out of date. The below assumes you're creating a plugin using the ...


0

Yes, it is possible to host your own plugin and have the plugin check for updates from your server. You need to put some custom code in your plugin to tell it to check with your server for updates. There are some frameworks to help you do that, try these: Plugin Update Checker Github Plugin Updater


1

Let me say beforehand that when using add_rewrite_rule() nothing is written to the htaccess file. Rewrite rules are stored in the database and handled by WordPress internally on PHP level. TL;DR: Rewrite rules do persist after plugin deletion, but probably not the way you'd expect it. When using add_rewrite_rule these rules are added in the options table ...


0

Plugins, like any other functions file in a theme are just extensions to your theme's functions.php file. Any file that extends the main functions.php has to be manually included into the main functions file. The reason for this is, only files and templates within Wordpress file structure gets auto laoded. There is no logic to regocnize and to include custom ...


0

try to add return false; after the ajax call. like this: jQuery.post(ajaxurl, data, function(response) { jQuery('.' + cellToReplace).html(response); }); return false; }); this way the ajax is called only once.


2

Is something missing in my theme? Most likely. If you're using WordPress 4.1, make sure there is no <title /> in your header.php and add the following to your functions.php: add_theme_support( 'title-tag' ); Otherwise, make sure the title tag looks like: <title><?php wp_title( '' ) ?></title> You should also have <?php ...


0

This is the screen you're referring to: That interface is a modal dialog created using javascript. Specifically, backbone.js. Internally WordPress stores files in the file system and creates a post for them of type attachment. This attachment post stores the title, caption and other information. Because of this, it's possible to have comments on an image, ...


1

You're using the admin_init hook to add menus - use admin_menu instead. The init hook runs early enough for wp-admin/menu.php to add it to the sidebar menu, but not for the plugin page loading in wp-admin/admin.php In other words, when you actually try to load the plugin page, your menu code hasn't fired and WordPress fails with that rather generic error.



Top 50 recent answers are included