WP Plugin permissions – create new files

I can think here of two possibillites. Use the wp-content/uploads maybe for your text-file because the file permission restriction are more or less bypassed in this directory. Put all stuff to wp_options and write a page Template imitating the text-file like page_text.php /* Template Name: Text-Template */ echo get_option(‘ads’, false); Create a page and asign … Read more

{status}_{post_type} does not run correctly?

WooCommerce has its own hooks for things like this. You shouldn’t rely on the underlying WordPress post-related hooks and functions when dealing with products and orders. WooCommerce is moving towards using custom database tables for products and orders instead of custom post types and while there’ll be hooks etc. added for backwards compatibility, you’ll be … Read more

catch urls with specific pattern and show specific content for them by plugin

There might be other ways, but what I would so is create a rewrite rule in your .htaccess file, something like: RewriteRule ^items/([0-9]*) /items/?page=$1 Now your user sees: http://mywordpress_site.com/items/1/ But behind the scenes, your site sees: http://mywordpress_site.com/items/?page=1 Then in your shortcode: $page = (int) $_GET[‘page’]; WP has tools in it to manage rewrites, and it … Read more

register_activation_hook not creating table

You create auto column sno int(10) NOT NULL AUTO_INCREMENT, and forget to define it as key, add PRIMARY KEY (sno) to your sql. $sql = “CREATE TABLE $table_name ( sno int(10) NOT NULL AUTO_INCREMENT, postid int(50) NOT NULL, subpostid varchar(5) NOT NULL, votingcount varchar(50) NOT NULL, postclicktime timestamp(5) NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (sno) … Read more

How to save the option’s new values plus old value without overwrite old one

You are misspelling the variables names. You define them as $new_value and $old_value with underscore that you forgot about. Except this your code working fine. function myplugin_update_field_foo( $new_value, $old_value ) { if ($new_value !== $old_value && is_array($old_value) && is_array($new_value)) { $new_value = array_unique( array_merge( $new_value, $old_value ) ); } return $new_value; } To get the … Read more