Skip to content
This repository was archived by the owner on Aug 1, 2021. It is now read-only.

Commit 82a5fe7

Browse files
1 parent f05abec commit 82a5fe7

File tree

6 files changed

+67
-26
lines changed

6 files changed

+67
-26
lines changed

composer.lock

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/composer/installed.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -371,17 +371,17 @@
371371
},
372372
{
373373
"name": "wp-content-framework/custom_post",
374-
"version": "v0.0.28",
375-
"version_normalized": "0.0.28.0",
374+
"version": "v0.0.29",
375+
"version_normalized": "0.0.29.0",
376376
"source": {
377377
"type": "git",
378378
"url": "https://github.com/wp-content-framework/custom_post.git",
379-
"reference": "a52d8bd5ec20c910fb081b9c6032c315689177c2"
379+
"reference": "0a7f1072d0dfb029729e68053b7e4035825a20ab"
380380
},
381381
"dist": {
382382
"type": "zip",
383-
"url": "https://api.github.com/repos/wp-content-framework/custom_post/zipball/a52d8bd5ec20c910fb081b9c6032c315689177c2",
384-
"reference": "a52d8bd5ec20c910fb081b9c6032c315689177c2",
383+
"url": "https://api.github.com/repos/wp-content-framework/custom_post/zipball/0a7f1072d0dfb029729e68053b7e4035825a20ab",
384+
"reference": "0a7f1072d0dfb029729e68053b7e4035825a20ab",
385385
"shasum": ""
386386
},
387387
"require": {
@@ -395,7 +395,7 @@
395395
"phake/phake": "~2.0",
396396
"phpunit/phpunit": "~5.7"
397397
},
398-
"time": "2019-03-16T05:24:13+00:00",
398+
"time": "2019-03-17T16:56:23+00:00",
399399
"type": "library",
400400
"installation-source": "dist",
401401
"notification-url": "https://packagist.org/downloads/",

vendor/wp-content-framework/custom_post/src/classes/models/custom_post.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/**
33
* WP_Framework_Custom_Post Classes Models Custom Post
44
*
5-
* @version 0.0.28
5+
* @version 0.0.29
66
* @author Technote
77
* @copyright Technote All Rights Reserved
88
* @license http://www.opensource.org/licenses/gpl-2.0.php GNU General Public License, version 2
@@ -404,7 +404,7 @@ private function redirect_post_location(
404404
global $typenow;
405405
if ( $this->is_valid_custom_post_type( $typenow ) ) {
406406
$custom_post = $this->get_custom_post_type( $typenow );
407-
$this->app->set_session( 'updated_message', sprintf( $this->translate( 'Updated %s data.<br>[Back to list page](%s)' ), $custom_post->get_post_type_single_name(), $custom_post->get_post_type_link() ), 60 );
407+
$this->app->set_session( 'updated_message', sprintf( $this->translate( 'Updated %s data.<br>[Back to list page](%s)' ), $this->translate( $custom_post->get_post_type_single_name() ), $custom_post->get_post_type_link() ), 60 );
408408
}
409409
}
410410

vendor/wp-content-framework/custom_post/src/deprecated/traits/custom_post.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/**
33
* WP_Framework_Custom_Post Deprecated Traits Custom Post
44
*
5-
* @version 0.0.28
5+
* @version 0.0.29
66
* @author Technote
77
* @copyright Technote All Rights Reserved
88
* @license http://www.opensource.org/licenses/gpl-2.0.php GNU General Public License, version 2
@@ -50,13 +50,13 @@ public function list_data( $instance, $is_valid = true, $per_page = null, $page
5050
],
5151
];
5252
empty( $where ) and $where = [];
53+
if ( $is_valid ) {
54+
$where['p.post_status'] = 'publish';
55+
}
5356
$total = $this->app->db->select_count( $table, null, $where );
5457
$total_page = isset( $per_page ) ? ceil( $total / $per_page ) : 1;
5558
$page = min( $total_page, $page );
5659
$offset = isset( $per_page ) && isset( $page ) ? $per_page * ( $page - 1 ) : null;
57-
if ( $is_valid ) {
58-
$where['p.post_status'] = 'publish';
59-
}
6060

6161
$list = $this->app->db->select( $table, $where, null, $limit, $offset, $orderby );
6262
if ( empty( $list ) ) {

vendor/wp-content-framework/custom_post/src/interfaces/custom_post.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/**
33
* WP_Framework_Custom_Post Interfaces Custom Post
44
*
5-
* @version 0.0.26
5+
* @version 0.0.29
66
* @author Technote
77
* @copyright Technote All Rights Reserved
88
* @license http://www.opensource.org/licenses/gpl-2.0.php GNU General Public License, version 2
@@ -211,6 +211,20 @@ public function get_list_data( $callback = null, $is_valid = true, $per_page = n
211211
*/
212212
public function pagination( $per_page, $page, $callback = null, $is_valid = true );
213213

214+
/**
215+
* @param bool $only_publish
216+
*
217+
* @return int
218+
*/
219+
public function count( $only_publish = false );
220+
221+
/**
222+
* @param bool $only_publish
223+
*
224+
* @return bool
225+
*/
226+
public function is_empty( $only_publish = false );
227+
214228
/**
215229
* @param array $params
216230
* @param array $where

vendor/wp-content-framework/custom_post/src/traits/custom_post.php

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/**
33
* WP_Framework_Custom_Post Traits Custom Post
44
*
5-
* @version 0.0.28
5+
* @version 0.0.29
66
* @author Technote
77
* @copyright Technote All Rights Reserved
88
* @license http://www.opensource.org/licenses/gpl-2.0.php GNU General Public License, version 2
@@ -70,8 +70,7 @@ private function register_post_type() {
7070
return;
7171
}
7272

73-
global $typenow;
74-
if ( $post_type === $typenow ) {
73+
if ( isset( $_REQUEST['post_type'] ) && $_REQUEST['post_type'] === $post_type ) {
7574
add_filter( "views_edit-{$post_type}", function ( $views ) {
7675
return $this->view_edit( $views );
7776
} );
@@ -88,10 +87,12 @@ private function register_post_type() {
8887
}
8988

9089
/**
90+
* @param string|null $as
91+
*
9192
* @return \WP_Framework_Db\Classes\Models\Query\Builder
9293
*/
93-
protected function query() {
94-
return $this->table( $this->get_related_table_name() );
94+
protected function query( $as = null ) {
95+
return $this->table( $this->get_related_table_name(), $as );
9596
}
9697

9798
/**
@@ -980,10 +981,8 @@ public function get_data( $id, $is_valid = true ) {
980981
* @return array
981982
*/
982983
public function get_list_data( $callback = null, $is_valid = true, $per_page = null, $page = 1 ) {
983-
$table = $this->get_related_table_name();
984984
$page = max( 1, $page );
985-
986-
$query = $this->table( $table, 't' )->alias_join_wp( 'posts', 'p', 'p.ID', 't.post_id' );
985+
$query = $this->query( 't' )->alias_join_wp( 'posts', 'p', 'p.ID', 't.post_id' );
987986
if ( $is_valid ) {
988987
$query->where( 'p.post_status', 'publish' );
989988
}
@@ -1039,6 +1038,34 @@ public function pagination( $per_page, $page, $callback = null, $is_valid = true
10391038
return $this->get_list_data( $callback, $is_valid, $per_page, $page );
10401039
}
10411040

1041+
/**
1042+
* @param bool $only_publish
1043+
*
1044+
* @return int
1045+
*/
1046+
public function count( $only_publish = false ) {
1047+
$query = $this->query( 't' )->alias_join_wp( 'posts', 'p', 'p.ID', 't.post_id' );
1048+
if ( $only_publish ) {
1049+
$query->where( 'p.post_status', 'publish' );
1050+
}
1051+
1052+
return $query->count();
1053+
}
1054+
1055+
/**
1056+
* @param bool $only_publish
1057+
*
1058+
* @return bool
1059+
*/
1060+
public function is_empty( $only_publish = false ) {
1061+
$query = $this->query( 't' )->alias_join_wp( 'posts', 'p', 'p.ID', 't.post_id' );
1062+
if ( $only_publish ) {
1063+
$query->where( 'p.post_status', 'publish' );
1064+
}
1065+
1066+
return ! $query->exists();
1067+
}
1068+
10421069
/**
10431070
* @param array $d
10441071
*

0 commit comments

Comments
 (0)