init( array( 'load_on_page' => 'wpbc-rules', 'container' => '.wpbc_rules_pagination', 'on_click' => 'wpbc_rules_pagination_click' // onclick = "javascript: wpbc_rules_listing_page( page_num );" - need to define this function in JS file ) ); $wpbc_pagination->show( // Its showing with JavaScript on document ready array( 'page_active' => 3, 'pages_count' => 20 ) ); OR (for showing with JavaScript) : */ class WPBC_Pagination { private $settings; /** * Get parameter Value * * @param string $parameter - name of parameter * * @return mixed */ public function get_settings( $parameter ){ if ( ! empty( $this->settings[ $parameter ] ) ) { return $this->settings[ $parameter ]; } else { return false; } } // //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// JS | CSS files //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /** * Define HOOKs for loading CSS and JavaScript files */ public function init_load_css_js() { // JS & CSS add_action( 'wpbc_enqueue_js_files', array( $this, 'js_load_files' ), 50 ); add_action( 'wpbc_enqueue_css_files', array( $this, 'enqueue_css_files' ), 50 ); } /** JSS */ public function js_load_files( $where_to_load ) { $in_footer = true; if ( ( is_admin() ) && ( in_array( $where_to_load, array( 'admin', 'both' ) ) ) ) { wp_enqueue_script( 'wpbc-pagination' , trailingslashit( plugins_url( '', __FILE__ ) ) . 'pagination.js' /* wpbc_plugin_url( '/_out/js/code_mirror.js' ) */ , array( 'wpbc_all' ), WP_BK_VERSION_NUM, $in_footer ); /** wp_localize_script( 'wpbc_all', 'wpbc_live_request_obj' , array( 'contacts' => '', 'reminders' => '' ) ); */ } } /** CSS */ public function enqueue_css_files( $where_to_load ) { if ( ( is_admin() ) && ( in_array( $where_to_load, array( 'admin', 'both' ) ) ) ) { wp_enqueue_style( 'wpbc-pagination', trailingslashit( plugins_url( '', __FILE__ ) ) . 'pagination.css', array(), WP_BK_VERSION_NUM ); } } // // //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// Templates //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public function init_load_templates() { add_action( 'wpbc_hook_settings_page_footer', array( $this, 'hook__page_footer_tmpl' ) ); } /** * Templates at footer of page * * @param $page string */ public function hook__page_footer_tmpl( $page ){ if ( $this->get_settings( 'load_on_page' ) === $page ) { $this->template__prev_next(); $this->template__items_per_page(); $this->template__active_page_in_selectbox(); } } /** * Pagination - " 1 - 9 of many | < > " * * @return void */ private function template__prev_next() { ?> /** * Init Pagination on start - define 'load_on_page', 'container', 'on_click' function * * @param array $params = array( 'load_on_page' => 'wpbc-settings', // defined at function in_page() { 'container' => '.wpbc_settings_pagination', // defined in function content(), like
'on_click' => 'wpbc_pagination_click_page' // onclick = "javascript: wpbc_pagination_click_page( page_active );" - need to define this function in JS file ); */ public function init( $params = array() ) { $defaults = array( 'load_on_page' => 'wpbc-settings', // defined at function in_page() { 'container' => '.wpbc_settings_pagination', // defined in function content(), like
'on_click' => 'wpbc_pagination_click_page' // onclick = "javascript: wpbc_pagination_click_page( page_active );" - need to define this function in JS file ); $this->settings = wp_parse_args( $params, $defaults ); $this->init_load_templates(); } /** * Show pagination * * @param array $params = array( 'page_active' => 1, 'pages_count' => 10 ) */ public function show( $params = array() ) { $defaults = array( 'page_active' => 1, 'pages_count' => 1, 'total_count' => 1 ); $params = wp_parse_args( $params, $defaults ); ?> init_load_css_js(); } //TODO: delete ../email-reminders/_src/css/o-pagination.css