*/ class TICA_Initiatives_Public { /** * The ID of this plugin. * * @since 1.0.0 * @access private * @var string $plugin_name The ID of this plugin. */ private $plugin_name; /** * The version of this plugin. * * @since 1.0.0 * @access private * @var string $version The current version of this plugin. */ private $version; /** * Initialize the class and set its properties. * * @since 1.0.0 * @param string $plugin_name The name of the plugin. * @param string $version The version of this plugin. */ public function __construct( $plugin_name, $version ) { $this->plugin_name = $plugin_name; $this->version = $version; } /** * Register the stylesheets for the public-facing side of the site. * * @since 1.0.0 */ public function enqueue_styles() { /** * This function is provided for demonstration purposes only. * * An instance of this class should be passed to the run() function * defined in TICA_Initiatives_Loader as all of the hooks are defined * in that particular class. * * The TICA_Initiatives_Loader will then create the relationship * between the defined hooks and the functions defined in this * class. */ wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/tica-initiatives-public.css', array(), $this->version, 'all' ); } /** * Register the JavaScript for the public-facing side of the site. * * @since 1.0.0 */ public function enqueue_scripts() { /** * This function is provided for demonstration purposes only. * * An instance of this class should be passed to the run() function * defined in TICA_Initiatives_Loader as all of the hooks are defined * in that particular class. * * The TICA_Initiatives_Loader will then create the relationship * between the defined hooks and the functions defined in this * class. */ wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/tica-initiatives-public.js', array( 'jquery' ), $this->version, false ); } public function initiatives_list_sc() { $list = ''; $paged = max( 1, get_query_var( 'paged' ) ); $initiatives_query = new WP_Query( [ 'post_type' => TICA_Initiatives::POST_TYPE, 'orderby' => TICA_Initiatives::DEFAULT_ORDERBY, 'order' => TICA_Initiatives::DEFAULT_ORDER, 'posts_per_page' => 20, 'paged' => $paged, ] ); if ( $initiatives_query->have_posts() ) { $pages = paginate_links( [ 'format' => ( get_option( 'permalink_structure' ) ) ? 'page/%#%/' : '?page=%#%', 'prev_text' => __('«'), 'next_text' => __('»'), 'total' => $initiatives_query->max_num_pages, 'current' => $paged, ] ); ob_start(); include plugin_dir_path( __FILE__ ) . 'partials/initiatives-list-sc.php'; $list = ob_get_contents(); ob_end_clean(); } return $list; } public function add_back_link( $content ) { global $post; if ( is_single() && TICA_Initiatives::POST_TYPE == $post->post_type ) { $back_link = ''; $initiatives_back_url = ''; $post_id = get_option( TICA_Initiatives::INITIATIVES_LIST_POST_ID_OPTION ); if ( $post_id ) { $initiatives_back_url = get_permalink( $post_id ); } if ( $initiatives_back_url ) { ob_start(); include plugin_dir_path( __FILE__ ) . 'partials/back-link.php'; $back_link = ob_get_contents(); ob_end_clean(); } $content = $back_link . $content; } return $content; } }