Advertisement
terorama

WP / API Examples

May 29th, 2013
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 36.62 KB | None | 0 0
  1. <?php
  2. //-------------------------------------------------
  3. define('WP_USE_THEMES', false);
  4. require('../wp-load.php');
  5. header('Content-type: text/html; charset=utf-8');
  6.  
  7. //-------------------------------------------------
  8. //               post types
  9. //-------------------------------------------------
  10.  
  11. echo '<h3>list of blog post types</h3>';
  12.  
  13. $post_types = get_post_types (array(),'objects');
  14.  
  15. foreach ($post_types as $post_type) {
  16.  
  17.    echo $post_type->name.'<br/>';
  18.    echo (integer)is_post_type_archive($post_type->name).'<br/>';
  19.     echo (integer)is_post_type_hierarchical($post_type->name).'<br/>';
  20.  
  21.    //echo get_post_type_archive_link( $post_type->name );
  22.    
  23. }
  24.  
  25. //-------------------------------------------------
  26. //             post type object
  27. //-------------------------------------------------
  28. stdClass Object
  29. (
  30.     [labels] => stdClass Object
  31.         (
  32.             [name] => Записи
  33.             [singular_name] => Запись
  34.          
  35.         )
  36.  
  37.     [description] =>
  38.     [publicly_queryable] => 1
  39.     [exclude_from_search] =>
  40.     [capability_type] => post
  41.     [map_meta_cap] => 1
  42.     [_builtin] => 1
  43.     [_edit_link] => post.php?post=%d
  44.     [hierarchical] =>
  45.     [public] => 1
  46.     [rewrite] =>
  47.     [has_archive] =>
  48.     [query_var] =>
  49.     [register_meta_box_cb] =>
  50.     [taxonomies] => Array
  51.         (
  52.         )
  53.  
  54.     [show_ui] => 1
  55.     [menu_position] =>
  56.     [menu_icon] =>
  57.     [can_export] => 1
  58.     [show_in_nav_menus] => 1
  59.     [show_in_menu] => 1
  60.     [show_in_admin_bar] => 1
  61.     [delete_with_user] => 1
  62.     [name] => post
  63.     [cap] => stdClass Object
  64.         (
  65.             [edit_post] => edit_post
  66.            
  67.         )
  68.  
  69.     [label] => Записи
  70. )
  71.  
  72. //-------------------------------------------------
  73. //               categories
  74. //-------------------------------------------------
  75.  
  76.    $cats = get_categories('hide_empty=0');
  77.  
  78.    $args = array('child_of'=>38);
  79.    $args = array('parent'=>38);
  80.    $args = array('parent'=>0);
  81.    $args = array('orderby'=>'slug'/*id, name, count, term_group*/);
  82.    $args = array('order'=>'desc');
  83.    $args = array('hierarchical '=>0);
  84.    $args = array('exclude'=>'1,24');
  85.    $args = array('include'=>'1,24');
  86.    $args = array('number'=>4);
  87.  
  88.    $cats = get_categories($args);
  89.  
  90.    foreach ($cats as $cat) {
  91.       echo '<pre>'.print_r($cat,true).'</pre>';
  92.    }
  93.  
  94.    $cats = get_all_category_ids();
  95.  
  96.    $cats = get_cat_id('Портфолио');
  97.    $cats = get_cat_name(24);
  98.    $cats = get_category(24, ARRAY_A);
  99.    $cats = get_category_by_path('lessons', true, ARRAY_A);
  100.    $cats = get_category_by_slug('lessons');
  101.    $cat  = get_the_category_by_ID(38);
  102.    $cats = get_category_link(38);
  103.  
  104.    $cats = get_category_parents(24 , true , '>>', true);
  105.    echo htmlentities($cats);
  106.  
  107.    echo $cats;
  108.  
  109.    $cats = get_ancestors(array('object_id'=>24,'object_type'=>'category')); //??
  110.  
  111.  $posts = get_posts('numberposts=4');
  112.  
  113.    foreach ($posts as $post ){
  114.      
  115.       $cats = get_the_category();
  116.       print_r($cats);
  117.       echo '<br/>';
  118.    }
  119.  
  120.   $cats = single_cat_title('>> ', false);
  121.   echo in_category('Разное', 694);
  122.   echo in_category(array('Разное','Блог'), 694);
  123.    
  124.   the_category ('>> ', 'single', 694);
  125.   the_category ('>> ', 'multiple', 694);
  126.  
  127.   echo (string)!function_exists('wp_category_checklist');
  128.  
  129.  
  130.   //----------------------------------
  131.   $args = array ('hierarchical'=>0);
  132.   $args = array ('order'=>'DESC');
  133.   $args = array ('show_count'=>1);
  134.   $args = array ('hide_empty'=>false);
  135.   $args = array ('use_desc_for_title'=>false);
  136.   $args = array ('child_of'=>38);
  137.   $args = array ('exclude'=>'38,24');
  138.   $args = array ('exclude_tree'=>'38'); //??
  139.   $args = array ('include'=>'38,24');
  140.   $args = array ('number'=>4);
  141.   $args = array ('depth'=>1);
  142.   $args = array ('pad_counts'=>1);
  143.   $args = array ('taxonomy'=>'category');
  144.   //  walker
  145.  
  146.  wp_list_categories($args);
  147. //----------------------------------
  148.  
  149.  
  150. //-------------------------------------------------
  151. //         category object
  152. //-------------------------------------------------
  153. stdClass Object
  154. (
  155.     [term_id] => 40
  156.     [name] => Портфолио
  157.     [slug] => portfolio
  158.     [term_group] => 0
  159.     [term_order] => 0
  160.     [term_taxonomy_id] => 44
  161.     [taxonomy] => category
  162.     [description] =>
  163.     [parent] => 0
  164.     [count] => 2
  165.     [cat_ID] => 40
  166.     [category_count] => 2
  167.     [category_description] =>
  168.     [cat_name] => Портфолио
  169.     [category_nicename] => portfolio
  170.     [category_parent] => 0
  171. )
  172. //-------------------------------------------------
  173. //                   tags
  174. //-------------------------------------------------
  175.  
  176. $args = array('orderby'=>'');
  177. $args = array('orderby'=>'name','order'=>'DESC');
  178. $args = array('hide_empty'=>false);
  179. $args = array('exclude'=>'29,31');
  180. $args = array('include'=>'29,31');
  181. $args = array('number'=>4);
  182. $args = array('offset'=>4);
  183. $args = array('fields'=>'ids');
  184. $args = array('fields'=>'names');
  185. $args = array('slug'=>'JQuery');
  186. $args = array('search'=>'J');
  187. $args = array('name__like'=>'J');
  188. $args = array('pad_counts'=>true);
  189. $args = array('get'=>'all');
  190. $args = array('child_of'=>0);
  191. $args = array('parent'=>0);
  192.  
  193. $tags = get_tags($args);
  194.  
  195. foreach ($tags as $tag) {
  196.    echo '<pre>'.print_r($tag,true).'</pre>';
  197. }
  198.  
  199. $tag = get_tag(20, ARRAY_A);
  200. echo '<pre>'.print_r($tag,true).'</pre>';
  201.  
  202. $tag = get_tag_link(20);
  203.  
  204. //------------------------------
  205. query_posts(array('numberposts'=>1, 'posts_per_page'=>1, 'cat'=>get_cat_id('Разное')));
  206.  
  207. while (have_posts()) {
  208.    the_post();
  209.    echo get_the_title().'<br/>';
  210.    echo get_the_tag_list ('<ul><li>','</li><li>','</li></ul>');
  211.    print_r (get_the_tags ());
  212. }
  213. //------------------------------
  214.  
  215.  
  216.  
  217.  
  218. //-------------------------------------------------
  219. //                 tag object
  220. //-------------------------------------------------
  221. stdClass Object
  222. (
  223.     [term_id] => 20
  224.     [name] => Javascript
  225.     [slug] => javascript
  226.     [term_group] => 0
  227.     [term_order] => 0
  228.     [term_taxonomy_id] => 20
  229.     [taxonomy] => post_tag
  230.     [description] => Javascript
  231.     [parent] => 0
  232.     [count] => 6
  233. )
  234. //-------------------------------------------------
  235. //              taxonomies
  236. //-------------------------------------------------
  237. $taxz = get_taxonomies(array(), 'objects');
  238.  
  239. foreach ($taxz as $tax) {
  240.    echo '<pre>'.print_r($tax,true).'</pre>';
  241. }
  242. //--------------------------
  243.  
  244. $args = array ('orderby'=>'count');
  245. $args = array ('orderby'=>'count','order'=>'ASC');
  246. $args = array ('hide_empty'=>false);
  247. $args = array ('exclude'=>array(40,39));
  248. $args = array ('include'=>array(40,39));
  249. $args = array ('exclude_tree'=>array(38));
  250. $args = array ('number'=>4);
  251. $args = array ('fields'=>'names');
  252. $args = array ('fields'=>'ids');
  253. $args = array ('fields'=>'id=>parent');
  254. $args = array ('hierarchical'=>false);
  255. $args = array ('child_of'=>38);
  256. $args = array ('name__like'=>'J');
  257. $args = array ('pad_counts'=>true);
  258. $args = array ('offset'=>4);
  259. $args = array ('search'=>'j');
  260.  
  261. $terms = get_terms('category', $args);
  262.  
  263. foreach ($terms as $term) {
  264.    echo '<pre>'.print_r($term,true).'</pre>';
  265. }
  266. //--------------------------
  267.  
  268. $inf = get_term(40,'category');
  269. $inf = get_term_by('slug','primary_dir', 'direction', ARRAY_A);
  270.  
  271. echo '<pre>'.print_r($inf,true).'</pre>';
  272.  
  273. $inf = get_term_by('slug','lessons', 'category', OBJECT);
  274.    $infc = get_term_children ($inf->term_id, 'category');
  275.  
  276.    echo '<pre>'.print_r($infc,true).'</pre>';
  277.  
  278.  echo get_term_link( 40, 'category');
  279.  
  280.  echo (integer)taxonomy_exists('direction');
  281.  echo (integer)taxonomy_exists('category');
  282.  
  283.  echo (integer)term_exists('portfolio','category');
  284.  echo (integer)term_exists('jquery','category','lessons');
  285.  
  286.  
  287.  
  288. //-------------------------------------------------
  289. //            taxonomy object
  290. //-------------------------------------------------
  291. stdClass Object
  292. (
  293.     [hierarchical] => 1
  294.     [update_count_callback] =>
  295.     [rewrite] => Array
  296.         (
  297.             [slug] => direction
  298.             [with_front] => 1
  299.             [hierarchical] =>
  300.             [ep_mask] => 0
  301.         )
  302.  
  303.     [query_var] => direction
  304.     [public] => 1
  305.     [show_ui] => 1
  306.     [show_tagcloud] => 1
  307.     [_builtin] =>
  308.     [labels] => stdClass Object
  309.         (
  310.             [name] => Direction
  311.             [singular_name] => Direction
  312.             [search_items] => Поиск рубрик
  313.             [popular_items] =>
  314.             [all_items] => Direction
  315.             [parent_item] => Родительская рубрика
  316.             [parent_item_colon] => Родительская рубрика:
  317.             [edit_item] => Изменить рубрику
  318.             [view_item] => Просмотреть рубрику
  319.             [update_item] => Обновить рубрику
  320.             [add_new_item] => Добавить новую рубрику
  321.             [new_item_name] => Название новой рубрики
  322.             [separate_items_with_commas] =>
  323.             [add_or_remove_items] =>
  324.             [choose_from_most_used] =>
  325.             [menu_name] => Direction
  326.             [name_admin_bar] => Direction
  327.         )
  328.  
  329.     [show_in_nav_menus] => 1
  330.     [label] => Direction
  331.     [cap] => stdClass Object
  332.         (
  333.             [manage_terms] => manage_categories
  334.             [edit_terms] => manage_categories
  335.             [delete_terms] => manage_categories
  336.             [assign_terms] => edit_posts
  337.         )
  338.  
  339.     [name] => direction
  340.     [object_type] => Array
  341.         (
  342.             [0] => digest
  343.         )
  344.  
  345. )
  346.  
  347. //-------------------------------------------------
  348. //               term object
  349. //-------------------------------------------------
  350. stdClass Object
  351. (
  352.     [term_id] => 40
  353.     [name] => Портфолио
  354.     [slug] => portfolio
  355.     [term_group] => 0
  356.     [term_order] => 0
  357.     [term_taxonomy_id] => 44
  358.     [taxonomy] => category
  359.     [description] =>
  360.     [parent] => 0
  361.     [count] => 2
  362. )
  363.  
  364. //-------------------------------------------------
  365. //                   pages
  366. //-------------------------------------------------
  367.  
  368. $args = array('sort_column'=>'post_title','sort_order'=>'ASC');
  369. $args = array('hierarchical'=>0);
  370. $args = array('exclude'=>array(299));
  371. $args = array('include'=>array(299));
  372. $args = array('child_of'=>0);
  373. $args = array('parent'=>0);
  374. $args = array('exclude_tree'=>0);
  375. $args = array('meta_key'=>'position','meta_value'=>'featured');
  376. $args = array('meta_key'=>'_wp_page_template');
  377. $args = array('authors'=>'dmkim1');
  378. $args = array('number'=>4);
  379. $args = array('offset'=>4);
  380. $args = array('post_status'=>'publish');
  381.  
  382. $pages = get_pages($args);
  383.  
  384.    foreach ($pages as $page) {
  385.       echo '<pre>'.print_r($page,true).'</pre>';
  386.    }
  387.  
  388. //-----------------------
  389.  
  390. $ids = get_all_page_ids();
  391. echo '<pre>'.print_r($ids,true).'</pre>';
  392.  
  393.   $page_id = 43;
  394.    $inf = get_page($page_id);
  395.    echo '<pre>'.print_r($inf,true).'</pre>';
  396.  
  397.   echo get_page_link(43);
  398.  
  399.    $inf = get_page_by_path('контакты', OBJECT);
  400.    $inf = get_page_by_title('contacts', OBJECT);
  401.    echo get_page_uri($inf->ID);
  402.  
  403. //------------------------
  404.  $args = array(
  405.  
  406.    'depth'        => 0,
  407.     'show_date'    => '',
  408.     'date_format'  => get_option('date_format'),
  409.     'child_of'     => 0,
  410.     'exclude'      => '',
  411.     'include'      => '',
  412.     'title_li'     => __('Pages'),
  413.     'echo'         => 1,
  414.     'authors'      => '',
  415.     'sort_column'  => 'menu_order, post_title',
  416.     'link_before'  => '',
  417.     'link_after'   => '',
  418.     'walker'       => '',
  419.     'post_type'    => 'page',
  420.         'post_status'  => 'publish'
  421.    );
  422.  
  423.    wp_list_pages($args);
  424.  
  425. //------------------------
  426.  $args = array(
  427.         'depth'       => 0,
  428.     'sort_column' => 'menu_order, post_title',
  429.     'menu_class'  => 'menu',
  430.     'include'     => '',
  431.     'exclude'     => '',
  432.     'echo'        => true,
  433.     'show_home'   => false,
  434.     'link_before' => '',
  435.     'link_after'  => '' );
  436.  
  437.    wp_page_menu($args);
  438.  
  439. //-------------------------------------------------
  440. //                page object
  441. //-------------------------------------------------
  442.  
  443. stdClass Object
  444. (
  445.     [ID] => 43
  446.     [post_author] => 1
  447.     [post_date] => 2013-02-28 15:21:53
  448.     [post_date_gmt] => 2013-02-28 11:21:53
  449.     [post_content] =>
  450.     [post_title] => front_page
  451.     [post_excerpt] =>
  452.     [post_status] => publish
  453.     [comment_status] => open
  454.     [ping_status] => open
  455.     [post_password] =>
  456.     [post_name] => front_page
  457.     [to_ping] =>
  458.     [pinged] =>
  459.     [post_modified] => 2013-02-28 15:21:53
  460.     [post_modified_gmt] => 2013-02-28 11:21:53
  461.     [post_content_filtered] =>
  462.     [post_parent] => 0
  463.     [guid] => http://dmkim1.bget.ru/?page_id=43
  464.     [menu_order] => 0
  465.     [post_type] => page
  466.     [post_mime_type] =>
  467.     [comment_count] => 0
  468.     [ancestors] => Array
  469.         (
  470.         )
  471.  
  472.     [filter] => raw
  473. )
  474.  
  475. //-------------------------------------------------
  476. //                comments
  477. //-------------------------------------------------
  478.    $args = array('status'=>'approve');
  479.    $args = array('orderby'=>'comment_ID','order'=>'DESC');
  480.    $args = array('offset'=>0,'number'=>1);
  481.    $args = array('post_id'=>623);
  482.    $args = array('user_id'=>1);
  483.  
  484.    $comments = get_comments($args);
  485.  
  486.    foreach ($comments as $comm) {
  487.       echo '<pre>'.print_r($comm,true).'</pre>';
  488.    }
  489.  
  490. //-------------------------
  491.  while (have_posts()) {
  492.     the_post();
  493.     $inf  = get_post(get_the_id());
  494.     if ($inf->comment_count==0)
  495.        continue;
  496.  
  497.     echo '<h2>'.get_the_title().'</h2><br/>';
  498.  
  499.     echo (integer)have_comments().'<br/>';
  500.     comments_number( 'no responses', 'one response', '% responses' );
  501.     echo '<br/>';
  502.  
  503.     $comms = get_comments (array('post_id'=>get_the_id()));
  504.     $comms = get_approved_comments (get_the_id());
  505.  
  506.  
  507.     foreach ($comms as $comm) {
  508.        echo get_avatar($comm, 32).'<br/>';
  509.        echo get_comment_author($comm->comment_ID).'<br/><br/>';
  510.        echo get_comment_text($comm->comment_ID).'<br/><br/>';
  511.        
  512.     }
  513.    
  514.   }
  515. //-------------------------
  516.  $num = 30415;
  517.   $inf =  get_comment($num);
  518.   echo '<pre>'.print_r($inf,true).'</pre>';
  519.  
  520. //-------------------------------------------------
  521. //              comment object
  522. //-------------------------------------------------
  523. stdClass Object
  524. (
  525.     [comment_ID] => 30415
  526.     [comment_post_ID] => 623
  527.     [comment_author] => Дмитрий
  528.     [comment_author_email] => susanyn@mail.ru
  529.     [comment_author_url] =>
  530.     [comment_author_IP] => 109.188.124.180
  531.     [comment_date] => 2013-05-10 16:12:40
  532.     [comment_date_gmt] => 2013-05-10 14:12:40
  533.     [comment_content] => test4
  534.     [comment_karma] => 0
  535.     [comment_approved] => 1
  536.     [comment_agent] => Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.64 Safari/537.31
  537.     [comment_type] =>
  538.     [comment_parent] => 30414
  539.     [user_id] => 1
  540. )
  541.  
  542.  
  543. //-------------------------------------------------
  544. //                   query_posts
  545. //-------------------------------------------------
  546. query_vars=
  547. Array
  548. (
  549.     [cat] => 40
  550.     [error] =>
  551.     [m] => 0
  552.     [p] => 0
  553.     [post_parent] =>
  554.     [subpost] =>
  555.     [subpost_id] =>
  556.     [attachment] =>
  557.     [attachment_id] => 0
  558.     [name] =>
  559.     [static] =>
  560.     [pagename] =>
  561.     [page_id] => 0
  562.     [second] =>
  563.     [minute] =>
  564.     [hour] =>
  565.     [day] => 0
  566.     [monthnum] => 0
  567.     [year] => 0
  568.     [w] => 0
  569.     [category_name] => portfolio
  570.     [tag] =>
  571.     [tag_id] =>
  572.     [author_name] =>
  573.     [feed] =>
  574.     [tb] =>
  575.     [paged] => 0
  576.     [comments_popup] =>
  577.     [meta_key] =>
  578.     [meta_value] =>
  579.     [preview] =>
  580.     [s] =>
  581.     [sentence] =>
  582.     [fields] =>
  583.     [category__in] => Array
  584.         (
  585.             [0] => 40
  586.         )
  587.  
  588.     [category__not_in] => Array
  589.         (
  590.         )
  591.  
  592.     [category__and] => Array
  593.         (
  594.         )
  595.  
  596.     [post__in] => Array
  597.         (
  598.         )
  599.  
  600.     [post__not_in] => Array
  601.         (
  602.         )
  603.  
  604.     [tag__in] => Array
  605.         (
  606.         )
  607.  
  608.     [tag__not_in] => Array
  609.         (
  610.         )
  611.  
  612.     [tag__and] => Array
  613.         (
  614.         )
  615.  
  616.     [tag_slug__in] => Array
  617.         (
  618.         )
  619.  
  620.     [tag_slug__and] => Array
  621.         (
  622.         )
  623.  
  624.     [ignore_sticky_posts] =>
  625.     [suppress_filters] =>
  626.     [cache_results] => 1
  627.     [update_post_term_cache] => 1
  628.     [update_post_meta_cache] => 1
  629.     [post_type] =>
  630.     [posts_per_page] => 7
  631.     [nopaging] =>
  632.     [comments_per_page] => 50
  633.     [no_found_rows] =>
  634.     [order] => DESC
  635. )
  636. //-------------------------------------------------
  637. $args = array('cat'=>40);
  638. $args = array('cat'=>-40);
  639.  
  640. $args = array('author'=>1);
  641. $args = array('author'=>'1,4');
  642. $args = array('author_name'=>'susanyn1975');
  643. $args = array('author'=>'-1');
  644. $args = array('cat'=>40);
  645. $args = array('category_name'=>'portfolio');
  646. //---------------------
  647. $args = array('category__in'=>get_cat_id('Портфолио'));
  648. $args = array('category__in'=>array(get_cat_id('Уроки'),get_cat_id('PHP')));
  649. $args = array('category__in'=>array(get_cat_id('PHP')));
  650.  
  651. $args = array('cat'=>'38,40');
  652. $args = array('category_name'=>'portfolio,PHP');
  653. $args = array('cat'=>'-40');
  654.  
  655. $args = array('category__and'=>array(get_cat_id('Уроки'),get_cat_id('PHP')));
  656. $args = array('category__and'=>array(get_cat_id('JQuery'),get_cat_id('PHP')));
  657.  
  658. $args = array('category__in'=>array(get_cat_id('JQuery'),get_cat_id('PHP')));
  659. $args = array('category__not_in'=>array(get_cat_id('JQuery'),get_cat_id('PHP')));
  660. //---------------------
  661. $args = array('tag_id'=>29);
  662. $args = array('tag'=>'jquery,ajax');
  663. $args = array('tag'=>'jquery+ajax');
  664. $args = array('tag__and'=>array(26,35));
  665. $args = array('tag__in'=>array(26,35));
  666. $args = array('tag__not_in'=>array(26,35));
  667. //---------------------
  668. $args = array('post_type'=>'digest');
  669. $args = array('post_type'=>'digest', 'direction'=>'primary_dir');
  670.  
  671. $args = array('post_type'=>'digest',
  672.          'tax_query'=>array('taxonomy'=>'direction','field'=>'slug','terms'=>'secondary_dir'));
  673.  
  674. //---------------------
  675. $args = array ('post_type'=>'post', 'posts_per_page'=>400,
  676.   'tax_query' => array ('relation'=>'OR',
  677.              array('taxonomy'=>'category','field'=>'slug','terms'=>array('php')),
  678.              array('taxonomy'=>'category','field'=>'slug','terms'=>array('jquery'))));
  679. //---------------------
  680. $args = array('s'=>'слайдшоу');
  681. //---------------------
  682. $args = array('page_id'=>299);
  683. $args = array('p'=>738);
  684. $args = array('pagename'=>'контакты');
  685. $args = array('post_parent'=>0);
  686. //---------------------
  687.  $args = array('post_type'=>'page', 'post__in'=>array(299));
  688.  $args = array('post_type'=>'page', 'post__not_in'=>array(299));
  689.  
  690.  $args = array('post_type'=>array('post','page','digest'), 'posts_per_page'=>400);
  691. //---------------------
  692. $args = array('post_status'=>'draft');
  693. $args = array('post_status'=>array('pending','draft'));
  694.  
  695. $args = array('post_status'=>'any','post_type'=>'attachment');
  696. //---------------------
  697. $args = array('posts_per_page'=>-1);
  698. $args = array('nopaging'=>true);
  699.  $args = array('offset'=>4);
  700. $args = array('paged'=>4);
  701. //---------------------
  702. $args = array('orderby'=>'title','order'=>'ASC');
  703. $args = array('orderby'=>'ID','order'=>'ASC');
  704. $args = array('orderby'=>'author','order'=>'ASC');
  705. $args = array('orderby'=>'name','order'=>'ASC');
  706. $args = array('orderby'=>'date','order'=>'ASC');
  707. $args = array('orderby'=>'modified','order'=>'DESC');
  708.  $args = array('orderby'=>'parent','order'=>'ASC');
  709. $args = array('orderby'=>'rand');
  710. $args = array('orderby'=>'comment_count','order'=>'DESC');
  711. args = array('post_type'=>'page', 'orderby'=>'menu_order','order'=>'ASC');
  712.  
  713. $args = array('meta_key'=>'_oxygen_post_location', 'orderby'=>'meta_value','order'=>'ASC');
  714. $args = array('orderby'=>'author title','order'=>'ASC');
  715. //---------------------
  716. $args = array('year'=>$date['year']);
  717. $args = array('year'=>$date['year'], 'monthnum'=>$date['month']);
  718. $args = array('year'=>$date['year'], 'monthnum'=>$date['month'], 'day'=>$date['mday']);
  719. //---------------------
  720. $week = date('W');
  721. $year = date('Y');
  722. $args = array('year'=>$year, 'w'=>$week);
  723.  
  724. $args = array('year'=>2012, 'monthnum'=>6);
  725. //---------------------
  726. $args = array('meta_key'=>'_oxygen_post_location');
  727. $args = array('meta_key'=>'_oxygen_post_location', 'meta_value'=>'featured');
  728. $args = array('meta_value'=>'featured');
  729.  
  730. $args = array('meta_key'=>'_oxygen_post_location', 'meta_value'=>'featured',
  731.        'meta_compare'=>'!=');
  732. //---------------------
  733.  $args = array('meta_query'=>array (
  734.        array(
  735.        'key'=>'_oxygen_post_location',
  736.        'value'=>'featured')
  737.        ));
  738. //---------------------
  739. $args = array('meta_query'=>array (
  740.        
  741.        'relation'=>'OR',
  742.  
  743.        array(
  744.        'key'=>'_oxygen_post_location',
  745.        'value'=>'featured'),
  746.  
  747.        array(
  748.        'key'=>'_oxygen_post_location',
  749.        'value'=>'featured',
  750.        'compare'=>'!=')
  751.        ));
  752.  
  753. //---------------------
  754. $args = array('perm'=>'readable');
  755.  
  756.  
  757. //-------------------------------------------------
  758.  
  759.  $q = new WP_Query($args);
  760.  print_r($q->post_count);
  761.  
  762.  while ($q->have_posts()) {
  763.     $q->next_post();
  764.     echo '<pre>'.print_r($q->post,true).'</pre>';
  765.  }
  766. //-------------------------------------------------
  767. $q = new WP_Query($args);
  768.  
  769.  echo 'query='.print_r($q->query, true).'<br/>';
  770.  //echo 'query_vars=<pre>'.print_r($q->query_vars, true).'</pre>';
  771.  echo 'queried_object = '.$q->queried_object.'<br/>';
  772.  echo 'queried_object_id = '.$q->queried_object_id.'<br/>';
  773.  echo 'post_count = '.$q->post_count.'<br/>';
  774.  echo 'found_posts = '.$q->found_posts.'<br/>';
  775.  echo 'max_num_pages = '.$q->max_num_pages.'<br/>';
  776.  
  777. /*
  778.  
  779. $is_single, $is_page, $is_archive, $is_preview, $is_date, $is_year, $is_month, $is_time, $is_author, $is_category, $is_tag, $is_tax, $is_search, $is_feed, $is_comment_feed, $is_trackback, $is_home, $is_404, $is_comments_popup, $is_admin, $is_attachment, $is_singular, $is_robots, $is_posts_page, $is_paged
  780.  
  781. */
  782.  
  783.  while ($q->have_posts()) {
  784.     $q->the_post();
  785.    
  786.     echo 'current_post = '.$q->current_post.'<br/>';
  787.  
  788.     echo get_the_title().'<br/>';
  789.     $inf = &get_children(get_the_id());
  790.     //echo '<pre>'.print_r ($inf, true).'</pre>';
  791.     //echo print_r(get_extended(get_the_content()),true).'<br/>';
  792.  
  793.     $z = get_next_post();
  794.     echo 'next='.$z->title.'<br/>';
  795.     $z = get_previous_post();
  796.     echo 'previous='.$z->title.'<br/>';
  797.      $z = get_adjacent_post();
  798.     echo 'adjacent='.$z->title.'<br/>';
  799.     $z = get_boundary_post();
  800.     echo 'boundary='.$z->title.'<br/>';
  801.  
  802.     echo get_permalink().'<br/>';
  803.     echo get_the_excerpt().'<br/>';
  804.  
  805.     echo (string)has_post_thumbnail(get_the_id()).'<br/>';
  806.     //echo get_the_post_thumbnail(get_the_id(),'thumbnail').'<br/>';
  807.     echo print_r(get_post_ancestors(get_the_id()),true).'<br/>';
  808.     echo get_post_mime_type(get_the_id()).'<br/>';
  809.     echo get_post_status(get_the_id()).'<br/>';
  810.     echo get_post_format(get_the_id()).'<br/>';
  811.     echo get_edit_post_link(get_the_id()).'<br/>';
  812.     echo get_delete_post_link(get_the_id()).'<br/>';
  813.  
  814.     echo print_r(get_the_category(get_the_id()),true).'<br/>';
  815.     echo print_r(get_the_tags(get_the_id()),true).'<br/>';
  816.  
  817.     echo get_the_time('d.m:Y H:i:s', get_the_id()).'<br/>';
  818.     echo get_the_date('d.m:Y H:i:s', get_the_id()).'<br/>';
  819.  
  820.    $y = get_the_time('Y', get_the_id());
  821.    $m = get_the_time('m', get_the_id());
  822.    $d = get_the_time('d', get_the_id());
  823.  
  824.    echo get_day_link ($y, $m, $d).'<br/>';
  825.    echo get_month_link ($y, $m).'<br/>';
  826.    echo get_year_link ($y, $m).'<br/>';
  827.  
  828.    $types = get_post_types(get_the_id(),'objects');
  829.    echo '<pre>'.print_r($types, true).'</pre>';
  830.  
  831.    echo get_post_type(get_the_id()).'<br/>';
  832.  
  833.      $flds = get_post_custom(get_the_id());
  834.      $flds = get_post_custom_keys(get_the_id());
  835.  
  836.    echo '<pre>'.print_r($flds,true).'</pre>';
  837.  
  838.     echo get_post_meta(get_the_id(), '_oxygen_post_location', true).'<br/>';
  839.  
  840.     //----------------------
  841.     echo get_the_term_list(get_the_id(),'category','<ul><li>','</li><li>','</li></ul>');
  842.  
  843.    echo '<pre>'.print_r(   get_the_terms(get_the_id(),'category')   ,true).'</pre>';
  844.  
  845.     $terms = wp_get_object_terms(get_the_id(),'category');
  846.  
  847.  
  848.  }
  849.  
  850. //-------------------------------------------------
  851. //               post object
  852. //-------------------------------------------------
  853. stdClass Object
  854. (
  855.     [ID] => 738
  856.     [post_author] => 1
  857.     [post_date] => 2013-05-10 13:38:24
  858.     [post_date_gmt] => 2013-05-10 11:38:24
  859.     [post_content] =>
  860. Страница плагина
  861.     [post_title] => Плагин для агрегации RSS лент DK RSS Digest
  862.     [post_excerpt] =>
  863.     [post_status] => publish
  864.     [comment_status] => open
  865.     [ping_status] => closed
  866.     [post_password] =>
  867.     [post_name] => %d0%bf%d0%bb%d0%b0%d0%b3%d0%b8%d0%bd-%d0%b4%d0%bb%d1%8f-%d0%b0%d0%b3%d1%80%d0%b5%d0%b3%d0%b0%d1%86%d0%b8%d0%b8-rss-%d0%bb%d0%b5%d0%bd%d1%82-dk-rss-digest
  868.     [to_ping] =>
  869.     [pinged] =>
  870.     [post_modified] => 2013-05-10 13:42:57
  871.     [post_modified_gmt] => 2013-05-10 11:42:57
  872.     [post_content_filtered] =>
  873.     [post_parent] => 0
  874.     [guid] => http://kimdm79.hostenko.com/?p=738
  875.     [menu_order] => 0
  876.     [post_type] => post
  877.     [post_mime_type] =>
  878.     [comment_count] => 0
  879.     [filter] => raw
  880.  
  881.  
  882. //-------------------------------------------------
  883. //                attachments
  884. //-------------------------------------------------
  885.  
  886.    $posts = get_posts('posts_per_page=5');
  887.  
  888.    foreach ($posts as $post) {
  889.  
  890.       setup_postdata($post);
  891.       echo get_the_title().'<br/>';
  892.      
  893.       $att = & get_children (array('post_type'=>'attachment','post_parent'=>get_the_id()));
  894.       foreach ($att as $attt) {
  895.  
  896.           echo (integer)wp_attachment_is_image($attt->ID).'<br/>';
  897.  
  898.           echo get_attached_file($attt->ID).'<br/><br/>';
  899.  
  900.           echo htmlentities( wp_get_attachment_image($attt->ID, 'medium')).'<br/><br/>';
  901.  
  902.           echo htmlentities(wp_get_attachment_link($attt->ID, 'medium')).'<br/><br/>';
  903.           echo htmlentities(wp_get_attachment_link($attt->ID, 'medium', true)).'<br/><br/>';
  904.            echo htmlentities(wp_get_attachment_link($attt->ID, 'medium', true,
  905.                     false, 'link to image')).'<br/><br/>';
  906.  
  907.            $inf = wp_get_attachment_image_src($attt->ID, 'large');
  908.            echo '<pre>'.print_r($inf, true).'</pre>';
  909.  
  910.            $inf = wp_get_attachment_metadata($attt->ID);
  911.            //echo '<pre>'.print_r($inf, true).'</pre>';
  912.            
  913.            echo wp_get_attachment_thumb_file($attt->ID).'<br/><br/>';
  914.            echo wp_get_attachment_thumb_url($attt->ID).'<br/><br/>';
  915.            echo wp_get_attachment_url($attt->ID).'<br/><br/>';
  916.  
  917.       }
  918.  
  919.    }
  920.  
  921. //-------------------------------------------------
  922. //              attachment object
  923. //-------------------------------------------------
  924. stdClass Object
  925. (
  926.     [ID] => 112
  927.     [post_author] => 1
  928.     [post_date] => 2012-03-26 10:27:20
  929.     [post_date_gmt] => 2012-03-26 08:27:20
  930.     [post_content] =>
  931.     [post_title] => IMG_5815
  932.     [post_excerpt] =>
  933.     [post_status] => inherit
  934.     [comment_status] => open
  935.     [ping_status] => open
  936.     [post_password] =>
  937.     [post_name] => img_5815
  938.     [to_ping] =>
  939.     [pinged] =>
  940.     [post_modified] => 2012-03-26 10:27:20
  941.     [post_modified_gmt] => 2012-03-26 08:27:20
  942.     [post_content_filtered] =>
  943.     [post_parent] => 0
  944.     [guid] => http://kimdm79.hostenko.com/wp-content/uploads/IMG_5815.jpg
  945.     [menu_order] => 0
  946.     [post_type] => attachment
  947.     [post_mime_type] => image/jpeg
  948.     [comment_count] => 0
  949.     [filter] => raw
  950. )
  951. //-------------------------------------------------
  952. //             attachment meta
  953. //-------------------------------------------------
  954. Array
  955. (
  956.     [width] => 993
  957.     [height] => 575
  958.     [hwstring_small] => height='74' width='128'
  959.     [file] => chase.png
  960.     [sizes] => Array
  961.         (
  962.             [thumbnail] => Array
  963.                 (
  964.                     [file] => chase-145x145.png
  965.                     [width] => 145
  966.                     [height] => 145
  967.                 ),
  968.             [big] => Array
  969.                 (
  970.                     [file] => chase-546x387.png
  971.                     [width] => 546
  972.                     [height] => 387
  973.                 )
  974.  
  975.         )
  976.  
  977.     [image_meta] => Array
  978.         (
  979.             [aperture] => 0
  980.             [credit] =>
  981.             [camera] =>
  982.             [caption] =>
  983.             [created_timestamp] => 0
  984.             [copyright] =>
  985.             [focal_length] => 0
  986.             [iso] => 0
  987.             [shutter_speed] => 0
  988.             [title] =>
  989.         )
  990.  
  991. //-------------------------------------------------
  992. //                  get_posts
  993. //-------------------------------------------------
  994.  
  995. $args = array('numberposts'=>300, 'posts_per_page'=>300);
  996. $args = array('offset'=>4);
  997. $args = array('category'=>40);
  998. $args = array('orderby'=>'title','order'=>'ASC');
  999. $args = array('include'=>'748,647');
  1000. $args = array('exclude'=>'748,647');
  1001. $args = array('meta_key'=>'_oxygen_post_location');
  1002. $args = array('meta_key'=>'_oxygen_post_location', 'meta_value'=>'featured');
  1003. $args = array('post_type'=>'attachment');
  1004. $args = array('post_mime_type'=>'image');
  1005. $args = array('post_parent'=>40);
  1006. $args = array('post_status'=>'draft');
  1007.  
  1008.  
  1009. $posts = get_posts($args);
  1010.  
  1011. foreach ($posts as $p) {
  1012.    echo $p->post_title.'<br/>';
  1013.    echo print_r(get_the_category($p->ID)).'<br/><br/>';
  1014.    echo print_r(get_post_meta($p->ID)).'<br/><br/>';
  1015. }
  1016. //-----------------
  1017.    $posts = get_posts('posts_per_page=5');
  1018.  
  1019.    foreach ($posts as $post) {
  1020.  
  1021.       setup_postdata($post);
  1022.       echo get_the_title().'<br/>';
  1023.       echo get_permalink().'<br/>';
  1024.       echo get_the_excerpt().'<br/>';
  1025.       echo get_the_date('d.m.Y H:i:s', get_the_id()).'<br/>';
  1026.       echo get_the_term_list(get_the_id(),'category','<ul><li>','</li><li>','</li></ul>');
  1027.       echo get_the_tag_list('<ul><li>','</li><li>','</li></ul>');
  1028.       echo get_the_author().'<br/>';
  1029.  
  1030.  
  1031. //-------------------------------------------------
  1032. //                   users
  1033. //-------------------------------------------------
  1034.  
  1035. echo (integer)is_user_logged_in().'<br/>';
  1036.  
  1037. //---------------------
  1038. $args = array('redirect'=>site_url());
  1039. $args = array('form_id'=>'zcustom_form');
  1040. $args = array('label_username'=>'Input user name');
  1041. $args = array('label_password'=>'Input password');
  1042. $args = array('label_remember'=>'remember credentials');
  1043. $args = array('label_log_in'=>'go');
  1044.  
  1045.   $args = array('id_username' => 'user_login',
  1046.         'id_password' => 'user_pass',
  1047.         'id_remember' => 'rememberme',
  1048.         'id_submit' => 'wp-submit');
  1049.  
  1050. $args = array('remember'=>false);
  1051. $args = array('value_username'=>'admin');
  1052. $args = array('value_remember'=>true);
  1053.  
  1054.    wp_login_form($args);
  1055. //---------------------
  1056.  
  1057.  $cnt = count_users();
  1058.   echo '<pre>'.print_r($cnt,true).'</pre>';
  1059.  
  1060. Array
  1061. (
  1062.     [total_users] => 25
  1063.     [avail_roles] => Array
  1064.         (
  1065.             [administrator] => 1
  1066.             [subscriber] => 24
  1067.         )
  1068.  
  1069. )
  1070. //---------------------
  1071.  $args = array('role'=>'administrator');
  1072.  $args = array('orderby'=>'display_name','order'=>'ASC');
  1073.  $args = array('orderby'=>'user_registered','order'=>'DESC');
  1074.  $args = array('offset'=>4);
  1075.  $args = array('search'=>'*mail*');
  1076.  $args = array('number'=>4);
  1077.  
  1078.  
  1079.   $users = get_users($args);
  1080.  
  1081.   foreach ($users as $user) {
  1082.      echo $user->display_name.'<br/>';
  1083.      echo count_user_posts($user->ID).'<br/>';
  1084.  
  1085.      $meta = get_user_meta($user->ID);
  1086.      $meta = get_the_author_meta('user_firstname', $user->ID);
  1087.  
  1088.      echo '<pre>'.print_r($meta,true).'</pre>';
  1089.  
  1090.  
  1091.      
  1092.   }
  1093.  
  1094.  
  1095. //---------------------
  1096.  
  1097. echo (integer)email_exists('test@gmail.com');
  1098.  
  1099. $user = get_user_by('slug', 'dmkim1');
  1100.  
  1101. $user = get_userdata(1);
  1102.  
  1103. echo (integer)username_exists('dmkim1');
  1104.  
  1105. echo get_author_posts_url(1);
  1106.  
  1107.  
  1108. //---------------------
  1109. $creds = array();
  1110. $creds['user_login'] = 'dmkim1';
  1111. $creds['user_password'] = '';
  1112. $creds['remember'] = true;
  1113. $user = wp_signon( $creds, false );
  1114.  
  1115. if ( is_wp_error($user) )
  1116.    echo $user->get_error_message();
  1117.  
  1118. echo get_current_user_id().'<br/>';
  1119.  
  1120. global $current_user;
  1121.  get_currentuserinfo();
  1122.  
  1123. //$current_user = wp_get_current_user();
  1124.  
  1125. echo '<pre>'.print_r($current_user,true).'</pre>';
  1126.  
  1127. //-------------------------------------------------
  1128. //                   user object
  1129. //-------------------------------------------------
  1130.     [0] => stdClass Object
  1131.         (
  1132.             [ID] => 9
  1133.             [user_login] => AntunaKatt120
  1134.             [user_pass] => $P$Bw1kVwpSlUpBh8ZJcfoacVICHuKPI5.
  1135.             [user_nicename] => antunakatt120
  1136.             [user_email] => blowown@nabobst.co.cc
  1137.             [user_url] =>
  1138.             [user_registered] => 2012-07-14 23:12:26
  1139.             [user_activation_key] =>
  1140.             [user_status] => 0
  1141.             [display_name] => AntunaKatt120
  1142.         )
  1143.  
  1144. //-------------------------------------------------
  1145. //             current user object
  1146. //-------------------------------------------------
  1147. WP_User Object
  1148. (
  1149.     [data] => stdClass Object
  1150.         (
  1151.             [ID] => 1
  1152.             [user_login] => dmkim1
  1153.             [user_pass] => $P$BycaOriW.ddAk797yLGr46jWErGaBy0
  1154.             [user_nicename] => dmkim1
  1155.             [user_email] => dmkim1979@gmail.com
  1156.             [user_url] =>
  1157.             [user_registered] => 2012-09-20 09:04:49
  1158.             [user_activation_key] =>
  1159.             [user_status] => 0
  1160.             [display_name] => dmkim1
  1161.         )
  1162.  
  1163.     [ID] => 1
  1164.     [caps] => Array
  1165.         (
  1166.             [administrator] => 1
  1167.         )
  1168.  
  1169.     [cap_key] => wp_capabilities
  1170.     [roles] => Array
  1171.         (
  1172.             [0] => administrator
  1173.         )
  1174.  
  1175.     [allcaps] => Array
  1176.         (
  1177.             [publish_posts] => 1
  1178.             [create_users] => 1
  1179.             [unfiltered_upload] => 1  
  1180.             [administrator] => 1
  1181.         )
  1182.  
  1183.     [filter] =>
  1184. )
  1185.  
  1186. //-------------------------------------------------
  1187. //-------------------------------------------------
  1188.  
  1189. echo backslashit('test/').'<br/>';  
  1190. \t\e\s\t/
  1191.  
  1192. echo htmlentities(balanceTags('<a href="#">inf', true)).'<br/>';
  1193. <a href="#">inf</a>
  1194.  
  1195. update_option('use_smilies', true);
  1196. echo convert_smilies(" :)");
  1197.  
  1198.  
  1199. echo 'esc_attr='.esc_attr('<a href="#">?test&\'z\'="test" http://test.com/test#@$%!~')."\r\n";
  1200. echo 'esc_html='.esc_html('<a href="#">?test&\'z\'="test" http://test.com/test#@$%!~')."\r\n";
  1201. echo 'esc_js='.esc_js('<a href="#">?test&\'z\'="test" http://test.com/test#@$%!~')."\r\n";  
  1202. echo 'esc_textarea='.esc_textarea('<a href="#">?test&\'z\'="test" http://test.com/test#@$%!~')."\r\n";  
  1203. echo 'esc_url='.esc_url('http://test.com/test?inf&test=zz')."\r\n";  
  1204. echo 'esc_url='.esc_url('test info & ')."\r\n";
  1205.  
  1206.  
  1207. esc_attr=&lt;a href=&quot;#&quot;&gt;?test&amp;&#039;z&#039;=&quot;test&quot; http://test.com/test#@$%!~
  1208. esc_html=&lt;a href=&quot;#&quot;&gt;?test&amp;&#039;z&#039;=&quot;test&quot; http://test.com/test#@$%!~
  1209. esc_js=&lt;a href=&quot;#&quot;&gt;?test&amp;\'z\'=&quot;test&quot; http://test.com/test#@$%!~
  1210. esc_textarea=&lt;a href=&quot;#&quot;&gt;?test&amp;&#039;z&#039;=&quot;test&quot; http://test.com/test#@$%!~
  1211. esc_url=http://test.com/test?inf&#038;test=zz
  1212. esc_url=http://testinfo&#038;
  1213.  
  1214. echo 'format_to_edit='.format_to_edit('<a href="#">?test&\'z\'="test" http://test.com/test#@$%!~')."\r\n";
  1215. echo 'format_to_post='.format_to_post('<a href="#">?test&\'z\'="test" http://test.com/test#@$%!~')."\r\n";
  1216. echo 'htmlentities2='.htmlentities2('<a href="#">?test&\'z\'="test" http://test.com/test#@$%!~')."\r\n";  
  1217. echo 'sanitize_email='.sanitize_email('<a href="#">?test&\'z\'="test" http://test.com/test#@$%!~')."\r\n";  
  1218. echo 'sanitize_text_field='.sanitize_text_field('http://test.com/test?inf&test=zz')."\r\n";  
  1219.  
  1220.  
  1221.  
  1222. format_to_edit=&lt;a href=&quot;#&quot;&gt;?test&amp;&#039;z&#039;=&quot;test&quot; http://test.com/test#@$%!~
  1223. format_to_post=<a href="#">?test&'z'="test" http://test.com/test#@$%!~
  1224. htmlentities2=&lt;a href=&quot;#&quot;&gt;?test&amp;&#39;z&#39;=&quot;test&quot; http://test.com/test#@$%!~
  1225. sanitize_email=
  1226. sanitize_text_field=http://test.com/test?inf&test=zz
  1227.  
  1228. //-------------------------------------------------
  1229. //-------------------------------------------------
  1230.  
  1231. wp_tag_cloud( $args );
  1232. category_description( $category_id );
  1233. tag_description( $tag = 0 )
  1234. has_tag( $tag = '', $post = null )
  1235. get_tag_link( $tag )
  1236. get_next_posts_link( $label, $max_page );
  1237. get_previous_posts_link( $label );
  1238. wp_link_pages( $args );
  1239. paginate_links( $args )
  1240. next_image_link( $size, $text );
  1241. previous_image_link( $size, $text );
  1242. wp_get_recent_posts( $args, $output )
  1243. wp_trim_excerpt( $text )
  1244. author_can( $post, $capability );
  1245. next_comments_link( $label, $max_page )
  1246. get_archive_template();
  1247. wp_get_theme( $stylesheet, $theme_root );
  1248. get_month_link( $year, $month );
  1249. date_i18n( $dateformatstring, $unixtimestamp, $gmt )
  1250.  
  1251. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement