Have custom post type Visibility be private by default, and have radio button also set to “Private”

Actually all you have to do is changing the script part to this: <script type=”text/javascript”> (function($){ try { $(‘#post-visibility-display’).text(‘<?php echo $visibility_trans; ?>’); $(‘#hidden-post-visibility’).val(‘<?php echo $visibility; ?>’); $(‘#visibility-radio-<?php echo $visibility; ?>’).attr(‘checked’, true); } catch(err){} }) (jQuery); </script> You see there is an additional line compared to your code. I’m referring you to my original answer for … Read more

Conditional On custom field plugin metabox

This can’t work because isset() returns true if there is a value, trueand false are values, ergo it won’t work. Do it like this instead: $premium = get_field(‘premium’); if ( ! $premium ) { // this is basically short for $premium == false echo ‘not premium’; }

functions.php return custom text

You can use get_blog_details() to do it. Use it the following way:– function greeting() { global $blog_id; $current_blog = get_blog_details( $blog_id ); if ( ‘one’ == $current_blog->blogname ) { echo ‘hello’; } elseif ( ‘two’ == $current_blog->blogname ) { echo ‘goodbye’; } }

call wp_insert_user in custom class doesnt work

In addition to the debugging advice from @s_ha_dum, you could try to catch the possible WP_Error thrown by wp_insert_user(): $user_id = wp_insert_user($params); if ( is_wp_error( $user_id ) ) { echo $user_id->get_error_message(); } else { printf( ‘User created with user_id = %d’, $user_id ); } Maybe the user already exists? You could also use email_exists() and … Read more

Breaking up multiple words and inserting an image after first word

Assuming you know that there will always be two words separated by a space, you can use explode. Something like this: $pieces = explode(” “, get_the_title()); $word1 = $pieces[0]; $word2 = $pieces[1]; $output .= ‘<li><a href=”‘.get_permalink().'” class=”‘.$page_id->post_name.’-link”><div class=”‘.$page_id->post_name.’-info”><h2>’.$word1.'</h2><div class=”‘.$page_id->post_name.’-img”>’.get_the_post_thumbnail($page->ID,’icons’).'</div><h2>’.$word2.'</h2></div></a></li>’;

User meta and public function security

functions.php is not more nor less secure than any other file in your WordPress installation, just like post meta is not more nor less secure than any other table in your WordPress database. That means that they are secure until your site is hacked. So question become “is WordPress secure?” and I think that: that … Read more

Execute Jquery when a specific page in my plugin is loading

You’ll need to get the screen id on the screen (or page) in question using get_current_screen() get_current_screen()->id Then, hook into it with the following: function my_script_function() { if ( strpos( get_current_screen()->id, ‘screen_id’ ) !== false ) { wp_enqueue_script( ‘my_javascript_handle’, ‘path/to/my/script.js’, ‘jquery’, ‘1.0’ ); } } add_action( ‘admin_enqueue_scripts’, ‘my_script_function’ ); This will enqueue your script properly … Read more