*/ class TICA_Publications_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_Publications_Loader as all of the hooks are defined * in that particular class. * * The TICA_Publications_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-publications-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_Publications_Loader as all of the hooks are defined * in that particular class. * * The TICA_Publications_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-publications-public.js', array( 'jquery' ), $this->version, false ); } public function publications_list_sc() { $list = ''; $paged = max( 1, get_query_var( 'paged' ) ); $publications_query = new WP_Query( [ 'post_type' => TICA_Publications::POST_TYPE, 'orderby' => TICA_Publications::DEFAULT_ORDERBY, 'order' => TICA_Publications::DEFAULT_ORDER, 'posts_per_page' => 20, 'paged' => $paged, ] ); if ( $publications_query->have_posts() ) { $pages = paginate_links( [ 'format' => ( get_option( 'permalink_structure' ) ) ? 'page/%#%/' : '?page=%#%', 'prev_text' => __('«'), 'next_text' => __('»'), 'total' => $publications_query->max_num_pages, 'current' => $paged, ] ); ob_start(); include plugin_dir_path( __FILE__ ) . 'partials/publications-list-sc.php'; $list = ob_get_contents(); ob_end_clean(); } return $list; } public function add_back_link( $content ) { global $post; if ( is_single() && TICA_Publications::POST_TYPE == $post->post_type ) { $back_link = ''; $publications_back_url = ''; $post_id = get_option( TICA_Publications::PUBLICATIONS_LIST_POST_ID_OPTION ); if ( $post_id ) { $publications_back_url = get_permalink( $post_id ); } if ( $publications_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; } }