array( 'name' => esc_html__( 'Paginate', 'mega' ), 'description' => esc_html__( 'Paginate Block', 'mega' )), 'before' => '
', 'after' => '
', 'class_base'=> 'ys-paginate' ); parent::__construct( __CLASS__, $args ); } public function settings( $form ) { $form->add_control( 'Mega_Control_onOff', array( 'label' => esc_html__( 'Show All', 'mega' ), 'value' => 0, 'name' => 'show_all' )); $form->add_sub_control( 'Mega_Control_Number', array( 'control' => 'show_all', 'control_value' => 'false', 'label' => esc_html__( 'Edge Size', 'mega' ), 'pro' => 1, 'value' => 1, 'name' => 'end_size' )); $form->add_sub_control( 'Mega_Control_Number', array( 'control' => 'show_all', 'control_value' => 'false', 'label' => esc_html__( 'Middle Size', 'mega' ), 'value' => 2, 'name' => 'mid_size' )); $form->add_control( 'Mega_Control_onOff', array( 'label' => esc_html__( 'Previous / Next', 'mega' ), 'pro' => 1, 'value' => 1, 'name' => 'prev_next' )); $form->add_sub_control( 'Mega_Control_Text', array( 'control' => 'prev_next', 'control_value' => 'true', 'label' => esc_html__( 'Previous', 'mega' ), 'value' => esc_html__( 'Previous', 'mega' ), 'name' => 'prev_text' )); $form->add_sub_control( 'Mega_Control_Text', array( 'control' => 'prev_next', 'control_value' => 'true', 'label' => esc_html__( 'Next', 'mega' ), 'value' => esc_html__( 'Next', 'mega' ), 'name' => 'next_text' )); } public function callback() { $this->mega['settings']['prev_text'] = '' . esc_html( $this->mega['settings']['prev_text'] ); $this->mega['settings']['next_text'] .= ''; if ( is_singular() ) { $args = array( 'echo' => false ); $paginate = paginate_comments_links( wp_parse_args( $args, $this->mega['settings'] )); } else { global $wp_query; $args = array( 'base' => str_replace( 999999999, '%#%', get_pagenum_link( 999999999 )), 'current' => max( 1, get_query_var( 'paged' )), 'total' => $wp_query->max_num_pages ); $paginate = paginate_links( wp_parse_args( $args, $this->mega['settings'] )); } mega_html( $paginate, $this->before(), $this->after() ); } }