Tag Info

Hot answers tagged

11

You can use wp_add_inline_style() to add to a stylesheet that you've already defined, such as in your plugin. This way an options screen or other user settings can affect the final style output. That could become very tedious, however, depending on how many changes you are giving the user the power over. However, it is the "best practice" as far as I know.


10

There is no index because the need for it was never strong enough. In ticket #14258 it was suggested, but since most options use autoload=yes by default, the index would be ignored anyway. There is also the still open ticket #24044 _Add index to wp_options to aid/improve performance_. I think you should create an index. It will survive upgrades. It might ...


2

I'm running 3 WP blogs on a Debian Squeeze large instance and was investigating why mysql was stuck on that host at 200% CPU usage and system load between 3 and 6. Looking at a 'show process list' inside mysql, we understood the wp_option table was involved in this issue so we executed: alter table wp_options add index autoload_idx(`autoload`); After ...


2

Of course it is not a good practice, since it will be considered as plugin error by Wordpress. It will output an error message on plugin activation like this: The plugin generated xxx characters of unexpected output during activation. If you notice “headers already sent” messages, problems with syndication feeds or other issues, try deactivating or removing ...


1

If you need to add dynamic CSS and don't have a stylesheet already added that you want to append it to, you can hook in and output it in the wp_head action hook: <?php function wpse_111373_output_plugin_css() { ?> <style type="text/css"> .innertrow { background-color: <?php get_option('css_value'); ?>;} </style> ...


1

If you'd dumped one of your $players you'd have seen the issue: object(WP_User)#126 (7) { ["data"]=> object(stdClass)#129 (10) { ["ID"]=> string(1) "9" ["user_login"]=> string(3) "abc" ["user_pass"]=> string(34) "$P$BmwzlhY1xP6JTBlbWzLPetkx8lB.Zo/" ["user_nicename"]=> string(3) "abc" ["user_email"]=> ...


1

There are some problems with your code, below code should answer your question how to delete, remove the subscribers from the options array. I heavily commented the code, which should explain what I did: Add form: //add the forum subscription option as part of the personal options on the profile and user edit screen add_action( 'personal_options', ...


1

It is pretty hard to tell since you didnt give a lot of information, but First, make sure both sites connect to the same database. Then add those lines in the wp-config.php of each sites to make sure your sites are going to get the right value of wp_home and wp_siteurl depending on which server your are connected to : define('WP_HOME','http://' . ...


1

If you just want to get rid of the \ characters in the string that's returned, you can use PHP's stripslashes(): $content = stripslashes( $content ); I'd recommend doing this on output rather than on input; WordPress adds the slashes as it sanitizes your data on insert, per update_option()'s Codex page, The $option (option name) value is escaped with ...


1

WP uses the GUID column of posts for links. You need to replace that, I use a script http://interconnectit.com/products/search-and-replace-for-wordpress-databases/ Just drop it in your root dir then follow the instructions. Hope this helps!


1

It was a 👼 character. Make sure you sanitize everything that gets written as field values, even if it's a username. trim(preg_replace("/[^\w\s]+/", "", $user->full_name)) I assumed there are no special characters in Instagram usernames. Never assume. I don't really use Instagram, just my plugin supports it. BTW it got truncated on the first occurrence ...


1

I believe it's possible to dynamically write a CSS file using PHP, but you'd have to find out more on it, I don't know much about it myself. I'm planning on doing it soon, as I noticed people putting a LOT of CSS in the on a theme I was working on. It's bad practice in many ways, so best to avoid where possible. Sadly there are only 24hrs in a day...!


1

You could do it this way (assumes that you know that all 3 images are there every time): <?php $headerimage_options = get_option( 'headerimage_options' ); $number = rand(1,3); if($number == 1) $number = ''; ?> <img title="<?php bloginfo( 'name' ); ?>" src="<?php echo esc_url( $headerimage_options['image' . $number] ); ...



Only top voted, non community-wiki answers of a minimum length are eligible