Last active
April 16, 2024 10:49
-
-
Save JuliaKiselyova/76df52461e72ca1a3902548131bb5ebd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| add_action( 'jet-engine/register-macros', function(){ | |
| class Get_Post_Count extends \Jet_Engine_Base_Macros { | |
| /** | |
| * @inheritDoc | |
| */ | |
| public function macros_tag() { | |
| return 'get_post_count'; | |
| } | |
| /** | |
| * @inheritDoc | |
| */ | |
| public function macros_name() { | |
| return esc_html__( 'Get Post Count', 'jet-engine' ); | |
| } | |
| /** | |
| * @inheritDoc | |
| */ | |
| public function macros_args() { | |
| return array( | |
| 'store' => array( | |
| 'label' => __( 'Store', 'jet-engine' ), | |
| 'type' => 'select', | |
| 'options' => \Jet_Engine\Modules\Data_Stores\Module::instance()->elementor_integration->get_store_options(), | |
| ), | |
| ); | |
| } | |
| /** | |
| * @inheritDoc | |
| */ | |
| public function macros_callback( $args = array() ) { | |
| $store = ! empty( $args['store'] ) ? $args['store'] : false; | |
| if ( ! $store ) { | |
| return 'not found'; | |
| } | |
| $post_id = jet_engine()->listings->data->get_current_object_id(); | |
| if( ! $post_id ){ | |
| return 'not found f'; | |
| } | |
| return \Jet_Engine\Modules\Data_Stores\Module::instance()->render->post_count( $store, $post_id ); | |
| } | |
| } | |
| new Get_Post_Count(); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment