Пример #1
0
 /**
  * Return the the Variable of your choosing
  * @since 0.1.0
  */
 static function vars($atts, $content = null)
 {
     self::$add_script = false;
     shortcode_atts(array('url' => 'site', 'post' => 'name', 'post_id' => ''), $atts);
     if (isset($atts['url'])) {
         switch ($atts['url']) {
             case 'site':
                 return site_url();
                 break;
             case 'template':
                 return get_template_directory_uri();
                 break;
             case 'register':
                 return wp_registration_url();
                 break;
             case 'login':
                 return wp_login_url();
                 break;
             case 'logout':
                 return wp_logout_url();
                 break;
             case 'wp_version':
                 return get_bloginfo('version');
                 break;
             default:
                 return site_url();
         }
     }
     if (isset($atts['post'])) {
         if (isset($atts['post_id'])) {
             $post = get_post($atts['post_id']);
         } else {
             global $post;
         }
         switch ($atts['post']) {
             case 'id':
                 return $post->ID;
             case 'slug':
                 return $post->post_name;
             case 'author':
                 return $post->post_author;
             case 'name':
                 return $post->post_name;
             case 'type':
                 return $post->post_type;
             case 'title':
                 return $post->post_title;
             case 'date':
                 return $post->post_date;
             case 'date_gmt':
                 return $post->post_date_gmt;
             case 'content':
                 return $post->post_content;
             case 'excerpt':
                 return $post->post_excerpt;
             case 'status':
                 return $post->post_status;
             case 'parent':
                 return $post->post_parent;
             case 'modified':
                 return $post->post_modified;
             case 'comment_count':
                 return $post->post_comment_count;
             case 'parent':
                 return $post->post_parent;
             default:
                 return $post->post_title;
         }
         return;
     }
 }