@@ -17,8 +17,8 @@ public function populate() {
1717 if ( ! class_exists ( 'Gappv_Admin ' ) ) {
1818 WP_CLI ::line ( __ ( 'Gappv_Admin Class does not exist! ' , 'gappv ' ) );
1919 }
20- $ gappv = new Gappv_Admin ( 'gappv ' , GAPPV_VERSION );
21- $ args = array (
20+ $ gappv = new Gappv_Admin ( 'gappv ' , GAPPV_VERSION );
21+ $ args = array (
2222 'post_type ' => 'post ' ,
2323 'post_status ' => 'publish ' ,
2424 'meta_query ' => array (
@@ -31,24 +31,22 @@ public function populate() {
3131 'orderby ' => 'date ' ,
3232 'order ' => 'DESC ' ,
3333 );
34- $ query = new WP_Query ( $ args );
35- $ output = '' ;
34+ $ query = new WP_Query ( $ args );
35+ $ output = '' ;
3636 if ( $ query ->have_posts () ) {
3737 while ( $ query ->have_posts () ) {
3838 $ query ->the_post ();
3939 $ post_id = get_the_ID ();
40- $ basename = basename ( get_permalink ( $ post_id ) );
41- $ link = '/ ' . $ basename . '/ ' ;
40+ $ link = wp_make_link_relative ( get_permalink ( $ post_id ) );
4241 $ post_date = get_the_date ( 'Y-m-d ' , $ post_id );
4342 $ views = $ gappv ->call_api ( $ post_id , $ link , $ post_date );
44- $ output .= WP_CLI ::line ( sprintf ( __ ( 'Post Path: %1$s, Views: %2$d ' , 'gappv ' ), $ link , $ views ) );
43+ $ output .= WP_CLI ::line ( sprintf ( __ ( 'Post Path: %1$s, Views: %2$d ' , 'gappv ' ), $ link , $ views ) );
4544 }
4645 }
4746 wp_reset_postdata ();
4847 }
4948
5049
51-
5250}
5351
5452WP_CLI ::add_command ( 'gappv ' , 'Gappv_Wp_Cli_Commands ' );
0 commit comments