how can I make content from a plugin hidden when user is logged in? [duplicate]

“[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 … Read more

Method not receiving attributes from shortcode call, general OOP problems

First, you have to initiate the class, something like: add_action( ‘init’, function() { $CsvImporter = new CsvImporter; } ); Also, you are using extract() wrong; extract() won’t build $attributes as an array. Anyway, extract() is not recommended any more and you should avoid using it. Also, note taht if ($attributes[‘mods’]) should be if ($attributes[‘type’] == … Read more

Output pure JSON wordpress

You will want to have your own url structure to output your “non html” output. Actually there are several ways, and it might be up to coding style preference to select one Add a Page and a template for the page that does what you need. You don’t have to output any html even in … Read more

The plugin generated xxx characters of unexpected output during activation

Anything outside the <?php ?> tags will be echoed as output since it has no conditions. The fastest way is to wrap in a function and output in the footer. add_action(‘wp_footer’,’custom_random_script’); function custom_random_script() { echo ‘<script> ……SCRIPT CONTENTS…… </script>’; } There is nothing technically wrong with outputting the script inside your existing function either, it … Read more

map urls to plugins

The general implementation of such “pretty” permalinks in WordPress is realm of WP Rewrite. However it is pretty wide topic and low level code is a bit of abomination. I would say these are three most common techniques for it, complexity ascending: Use WordPress native data structures (such as Custom Post Types and/or Taxonomies) and … Read more

wordpress plugin | short code issue

Without seeing your code it is impossible to be sure, but my guess is that you’re echoing the output of your shortcode instead of returning it. function my_shortcode($atts){ //do shortcode logic echo $result; //This is wrong and would do what you describe. } function my_shortcode($atts){ //do shortcode logic return $result; //This is what you should … Read more