Advertisement
SapphireWolf

Broken Author Site Snippets

Sep 13th, 2023
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.99 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4.  * Current year
  5.  *
  6.  * Shortcode for inserting the current year into a post or page..
  7.  *
  8.  * This is a sample snippet. Feel free to use it, edit it, or remove it.
  9.  */
  10. add_shortcode( 'code_snippets_export_4', function () {
  11.     ob_start();
  12.     ?>
  13.  
  14.     <?php echo date( 'Y' ); ?>
  15.  
  16.     <?php
  17.     return ob_get_clean();
  18. } );
  19.  
  20. /**
  21.  * Metabox - Counselor Name Post Title [Counselor]
  22.  */
  23. add_action( 'rwmb_frontend_after_save_post', 'update_bio_post_title');
  24. function update_bio_post_title( $object ) {
  25.    
  26.     $post_type = $object->post_type;
  27.     if ( 'bio' == $post_type ){
  28.     $post_id = $object->post_id;
  29.     // Get the field value
  30.     $my_meta = rwmb_meta( 'counselor_full_name', '', $post_id );
  31.  
  32.     // Get the post title
  33.     $my_post_title = get_the_title( $post_id );
  34.    
  35.     // Prepare update post
  36.     $post_slug = sanitize_title_with_dashes ($my_post_title,'','save');
  37.     $post_slugsan = sanitize_title($my_meta);
  38.    
  39.     $my_post_title = array(
  40.         'ID' => $post_id,
  41.         'post_title' => $my_meta,
  42.     'post_name' => $post_slugsan,
  43.     );
  44.  
  45.     wp_update_post( $my_post_title );}
  46. }
  47.  
  48. /**
  49.  * Metabox - Counselor Name Post Title [Coach]
  50.  */
  51. add_action( 'rwmb_frontend_after_save_post', 'update_coach_bio_post_title');
  52. function update_coach_bio_post_title( $object ) {
  53.    
  54.     $post_type = $object->post_type;
  55.     if ( 'coach-bio' == $post_type ){
  56.     $post_id = $object->post_id;
  57.     // Get the field value
  58.     $my_meta = rwmb_meta( 'counselor_full_name', '', $post_id );
  59.  
  60.     // Get the post title
  61.     $my_post_title = get_the_title( $post_id );
  62.    
  63.     // Prepare update post
  64.     $post_slug = sanitize_title_with_dashes ($my_post_title,'','save');
  65.     $post_slugsan = sanitize_title($my_meta);
  66.    
  67.     $my_post_title = array(
  68.         'ID' => $post_id,
  69.         'post_title' => $my_meta,
  70.     'post_name' => $post_slugsan,
  71.     );
  72.  
  73.     wp_update_post( $my_post_title );}
  74. }
  75.  
  76. /**
  77.  * Metabox - Counselor Name Post Title [Integration]
  78.  */
  79. add_action( 'rwmb_frontend_after_save_post', 'update_integration_bio_post_title');
  80. function update_integration_bio_post_title( $object ) {
  81.    
  82.     $post_type = $object->post_type;
  83.     if ( 'integration-bio' == $post_type ){
  84.     $post_id = $object->post_id;
  85.     // Get the field value
  86.     $my_meta = rwmb_meta( 'counselor_full_name', '', $post_id );
  87.  
  88.     // Get the post title
  89.     $my_post_title = get_the_title( $post_id );
  90.    
  91.     // Prepare update post
  92.     $post_slug = sanitize_title_with_dashes ($my_post_title,'','save');
  93.     $post_slugsan = sanitize_title($my_meta);
  94.    
  95.     $my_post_title = array(
  96.         'ID' => $post_id,
  97.         'post_title' => $my_meta,
  98.     'post_name' => $post_slugsan,
  99.     );
  100.  
  101.     wp_update_post( $my_post_title );}
  102. }
  103.  
  104. /**
  105.  * Remove Editor and Author from Squirrly
  106.  */
  107. add_filter('sq_load_snippet', function(){
  108.     if(current_user_can('editor')){
  109.         return false;
  110.     }
  111.     if(current_user_can('author')){
  112.         return false;
  113.     }
  114.     return true;
  115. });
  116.  
  117. /**
  118.  * Hide Author in Embeds
  119.  */
  120. add_filter( 'oembed_response_data', 'disable_embeds_filter_oembed_response_data_' );
  121. function disable_embeds_filter_oembed_response_data_( $data ) {
  122.     unset($data['author_url']);
  123.     unset($data['author_name']);
  124.     return $data;
  125. }
  126.  
  127. /**
  128.  * Oxygen Builder Password
  129.  */
  130. if( function_exists('oxygen_vsb_register_condition') ) {
  131.  
  132.     global $oxy_condition_operators;
  133.  
  134.     oxygen_vsb_register_condition('Has Password', array('options'=>array('true', 'false'), 'custom'=>false), array('=='), 'has_password_callback', 'Post');
  135.  
  136.     function has_password_callback($value, $operator) {
  137.  
  138.         if( $value == "true" && post_password_required( get_the_ID() ) ) {
  139.           return true;
  140.         } else if( $value == "false" && !post_password_required( get_the_ID() ) ) {
  141.           return true;
  142.         } else {
  143.           return false;
  144.         }
  145.  
  146.     }
  147.  
  148. }
  149.  
  150. /**
  151.  * WordPress Password Protection
  152.  */
  153. add_shortcode( 'code_snippets_export_14', function () {
  154.     ob_start();
  155.     ?>
  156.  
  157.     <?php
  158.     echo get_the_password_form();
  159.     ?>
  160.  
  161.     <?php
  162.     return ob_get_clean();
  163. } );
  164.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement