Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //-------------------------------------------------
- define('WP_USE_THEMES', false);
- require('../wp-load.php');
- header('Content-type: text/html; charset=utf-8');
- //-------------------------------------------------
- ?>
- <style type="text/css">
- div {
- float:left;
- margin-right:10px;
- }
- </style>
- <?php
- //post_info();
- //diff();
- //mk_cats4();
- mk_post();
- //-------------------------------------------------
- function mk_post() {
- $my_post = array(
- 'post_title' => 'test auto post',
- 'post_content' =>
- 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. '.
- 'Etiam id tortor lacus. Donec sapien nisl, '.
- 'tincidunt sed sollicitudin nec, dictum nec quam. ',
- 'post_status' => 'publish',
- 'post_author' => 1,
- 'post_category' => array(4)
- );
- // Insert the post into the database
- wp_insert_post( $my_post );
- }
- //-------------------------------------------------
- function mk_cats4() {
- $args = array(
- 'name'=> 'test base 7 category',
- 'description'=>'test inserting category',
- 'slug'=>sanitize_title('test base 7 category'),
- 'parent'=>''
- );
- $inf = get_category(16, ARRAY_A);
- //if (term_exists('test base 7 -category'))
- // get_term($term_id, $taxonomy);
- if (!$inf)
- wp_insert_term('test base 7 -category', 'category', $args);
- else
- wp_update_term(16, 'category', $args);
- foreach (array(11,12,13,14,15,17,18) as $num) {
- $inf = get_category($num, ARRAY_A);
- if ($inf) {
- wp_delete_term($num, 'category');
- }
- }
- }
- //-------------------------------------------------
- function mk_cats() {
- require_once(ABSPATH . "wp-admin/includes/taxonomy.php");
- $my_cat = array(
- 'cat_ID' =>11,
- 'cat_name' => 'test base 4 category',
- 'category_description' => 'A Cool Category',
- 'category_nicename' => 'testcategory4-slug',
- 'category_parent' => '');
- $my_cat_id = wp_insert_category($my_cat);
- echo $my_cat_id;
- }
- //-------------------------------------------------
- function post_info() {
- $args = array('post_type'=>'post');
- $q = new WP_Query($args);
- while ($q->have_posts()) {
- $q->the_post();
- echo '<br/><br/>';
- the_id();echo ' ';the_title();echo ' '; the_date(); echo ' ';the_author(); echo '<br/>';
- echo 'post_format='.get_post_format(get_the_id()).'<br/>';
- $cats = get_the_category(get_the_id());
- if ($cats) {
- echo '<br/>categories:<br/><br/>';
- foreach ($cats as $cat) {
- //echo '<pre>'.print_r($cat, true).'</pre>';
- echo 'category='.$cat->name.'<br/>';
- echo 'cat_term_id='.$cat->term_id.'<br/>';
- echo 'cat_link='.get_category_link($cat->term_id).'<br/>';
- echo 'cat_desc='.$cat->description.'<br/>';
- echo 'cat_slug='.$cat->slug.'<br/>';
- echo 'cat_id='.$cat->cat_ID.'<br/>';
- echo 'cat_name='.$cat->cat_name.'<br/>';
- echo 'cat_parent='.$cat->category_parent.'<br/>';
- echo 'cat_parents='.get_category_parents($cat->cat_ID, false, ',').'<br/>';
- }
- }
- $tags = get_the_tags(get_the_id());
- if ($tags) {
- echo '<br/>tags<br/><br/>';
- foreach ($tags as $tag) {
- //echo '<pre>'.print_r($tag, true).'</pre>';
- echo 'tag_id='.$tag->term_id.'<br/>';
- echo 'tag_name='.$tag->name.'<br/>';
- echo 'tag_slug='.$tag->slug.'<br/>';
- echo 'tag_desc='.$tag->description.'<br/>';
- echo 'tag_parent='.$tag->parent.'<br/>';
- echo 'tag_link='.get_tag_link($tag->term_id).'<br/><br/>';
- }
- }
- $taxonomies = get_the_taxonomies(get_the_id());
- if ($taxonomies) {
- echo '<br/>taxonomies<br/><br/>';
- foreach ($taxonomies as $taxo) {
- echo $taxo.'<br/>';
- }
- }
- // the_category();
- // the_tags();
- // the_taxonomies();
- // the_terms(get_the_id(),'category');
- }
- }
- //-------------------------------------------------
- function diff() {
- wp_tag_cloud();
- echo '<br/><br/>';
- wp_list_categories();
- echo '<br/><br/>';
- echo '<pre>'.print_r(get_the_taxonomies(), true).'</pre>';
- echo '<br/><br/>';
- $tags = get_tags();
- $html = '<div class="post_tags">';
- foreach ( $tags as $tag ) {
- $tag_link = get_tag_link( $tag->term_id );
- $html .= "<a href='{$tag_link}' title='{$tag->name} Tag' class='{$tag->slug}'>";
- $html .= "{$tag->name}</a>";
- }
- $html .= '</div>';
- echo $html;
- }
- //-------------------------------------------------
- function get_meta() {
- $args = array('post_type'=>'post');
- $q = new WP_Query($args);
- while ($q->have_posts()) {
- $q->the_post();
- the_id();echo ' ';the_title();echo ' '; the_date(); echo ' ';the_author(); echo '<br/>';
- $mt = get_post_meta(get_the_id() );
- echo '<pre>'.print_r($mt, true).'</pre>';
- //echo implode('<br/>',array_keys($mt)).'<br/>';
- }
- }
- //-------------------------------------------------
- function get_info4() {
- echo '<div><h3>post types</h3>';
- $post_types=get_post_types('','objects');
- foreach ($post_types as $p ) {
- echo 'name='.$p->name.'<br/>';
- echo 'label='.$p->label.'<br/>';
- echo 'description='.$p->description.'<br/>';
- echo 'labels[name]='.$p->labels->name.'<br/>';
- echo 'edit_link='.$p->_edit_link.'<br/>';
- echo str_repeat('-',50).'<br/>';
- }
- echo '</div>';
- }
- ?>
- <?php
- //-------------------------------------------------
- define('WP_USE_THEMES', false);
- require('../wp-load.php');
- header('Content-type: text/html; charset=utf-8');
- //-------------------------------------------------
- upd_comms();
- //-------------------------------------------------
- function check_atts() {
- $args = array('post_type'=>'post', 'post_status'=>'published');
- $que = new WP_Query($args);
- while ($que->have_posts()) {
- $que->the_post();
- $attachments =
- get_children( array('post_parent' => get_the_ID(),
- 'post_type' => 'attachment',
- 'post_mime_type' => 'image') );
- if ( $attachments ) {
- echo '<br/>'; the_ID(); echo ' - ';the_title(); echo '<br/>';
- foreach ($attachments as $att) {
- echo print_r(wp_get_attachment_image_src( $att->ID, 'full' ),true).'<br/>';
- }
- }
- }
- }
- //-------------------------------------------------
- function trim4($a) {
- return substr($a,0,3);
- }
- //--------------------------
- function upd_comms() {
- $comments = get_comments();
- echo '<h3>empty comments</h3>';
- foreach ($comments as $c) {
- if (trim($c->comment_content, "\r\n\t\0 ")=='') {
- echo $c->comment_ID.' '.$c->comment_author.' '.$c->comment_author_url.'<br/>';
- }
- }
- }
- //--------------------------
- function upd_commsu() {
- $args = array(
- 'order'=>'DESC'
- );
- $comments = get_comments($args);
- echo '<ul>';
- foreach($comments as $c) :
- $comm = get_comment( $c->comment_ID, ARRAY_A);
- echo '<li>';
- if (count(explode(' ', $comm['comment_author']))>1) {
- echo 'test'.'<br/>';
- $s = $comm['comment_author'];
- $comm['comment_author']=implode(array_filter(array_map('trim4', explode(' ',ucwords(strtr($s, '-_/\+-=',' '))))));
- wp_update_comment($comm);
- }
- endforeach;
- echo '</ul>';
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement