' . $located . '' ), '1.0' ); return; } // Allow 3rd party plugin filter template file from their plugin. $located = apply_filters( 'rttpg_get_template', $located, $template_name, $args ); do_action( 'rttpg_before_template_part', $template_name, $located, $args ); include $located; do_action( 'rttpg_after_template_part', $template_name, $located, $args ); } /** * Get template content and return * * @param string $template_name Template name. * @param array $args Arguments. (default: array). * @param string $template_path Template path. (default: ''). * @param string $default_path Default path. (default: ''). * * @return string */ public static function get_template_html( $template_name, $args = [], $template_path = '', $default_path = '' ) { ob_start(); self::get_template( $template_name, $args, $template_path, $default_path ); return ob_get_clean(); } /** * Locate template. * * @param string $template_name Template. * @param string $template_path Path. * @param string $default_path Default path. * * @return mixed|void */ public static function locate_template( $template_name, $template_path = '', $default_path = '' ) { $template_name = $template_name . '.php'; if ( ! $template_path ) { $template_path = rtTPG()->get_template_path(); } if ( ! $default_path ) { $default_path = rtTPG()->default_template_path() . '/templates/'; } // Look within passed path within the theme - this is priority. $template_files = []; $template_files[] = trailingslashit( $template_path ) . $template_name; $template = locate_template( apply_filters( 'rttpg_locate_template_files', $template_files, $template_name, $template_path, $default_path ) ); // Get default template/. if ( ! $template ) { $template = trailingslashit( $default_path ) . $template_name; } return apply_filters( 'rttpg_locate_template', $template, $template_name ); } /** * Mark something as being incorrectly called. * * @param string $function — The function that was called. * @param string $message — A message explaining what has been done incorrectly. * @param string $version — The version of WordPress where the message was added. * * @return void */ public static function doing_it_wrong( $function, $message, $version ) { // phpcs:disable $message .= ' Backtrace: ' . wp_debug_backtrace_summary(); _doing_it_wrong( $function, $message, $version ); // phpcs:enable } /** * Verify nonce. * * @return bool */ public static function verifyNonce() { $nonce = isset( $_REQUEST[ rtTPG()->nonceId() ] ) ? sanitize_text_field( wp_unslash( $_REQUEST[ rtTPG()->nonceId() ] ) ) : null; $nonceText = rtTPG()->nonceText(); if ( ! wp_verify_nonce( $nonce, $nonceText ) ) { return false; } return true; } /** * @param $data * @param $temp_path * * @return void */ public static function tpg_template( $data, $temp_path = 'elementor' ) { $layout = str_replace( '-2', '', $data['layout'] ); $template_name = '/the-post-grid/' . $temp_path . '/' . $layout . '.php'; if ( file_exists( STYLESHEETPATH . $template_name ) ) { $file = STYLESHEETPATH . $template_name; } else if ( file_exists( TEMPLATEPATH . $template_name ) ) { $file = TEMPLATEPATH . $template_name; } else { $file = RT_THE_POST_GRID_PLUGIN_PATH . '/templates/' . $temp_path . '/' . $layout . '.php'; if ( ! file_exists( $file ) ) { if ( rtTPG()->hasPro() ) { $file = RT_THE_POST_GRID_PRO_PLUGIN_PATH . '/templates/' . $temp_path . '/' . $layout . '.php'; } else { $layout = substr( $layout, 0, - 1 ); $layout = strpos( $layout, '1' ) ? str_replace( '1', '', $layout ) : $layout; $file = RT_THE_POST_GRID_PLUGIN_PATH . '/templates/' . $temp_path . '/' . $layout . '1.php'; } } } ob_start(); include $file; echo ob_get_clean(); } /** * @param $data * * @return string */ public static function tpg_template_path( $data, $temp_path = 'elementor' ) { $layout = str_replace( '-2', '', $data['layout'] ); $template_name = '/the-post-grid/' . $temp_path . '/' . $layout . '.php'; $path = RT_THE_POST_GRID_PLUGIN_PATH . '/templates/' . $temp_path . '/'; if ( file_exists( STYLESHEETPATH . $template_name ) ) { $path = STYLESHEETPATH . '/the-post-grid/' . $temp_path . '/'; } else if ( file_exists( TEMPLATEPATH . $template_name ) ) { $path = TEMPLATEPATH . '/the-post-grid/' . $temp_path . '/'; } else { $template_path = RT_THE_POST_GRID_PLUGIN_PATH . '/templates/' . $temp_path . '/' . $layout . '.php'; if ( ! file_exists( $template_path ) && rtTPG()->hasPro() ) { $path = RT_THE_POST_GRID_PRO_PLUGIN_PATH . '/templates/' . $temp_path . '/'; } } return $path; } /** * Get Post Pagination, Load more & Scroll markup * * @param $query * @param $data * * @return false|string|void */ public static function get_pagination_markup( $query, $data ) { if ( 'show' !== $data['show_pagination'] ) { return; } $htmlUtility = null; $posts_loading_type = $data['pagination_type']; $posts_per_page = ( isset( $data['display_per_page'] ) && $data['display_per_page'] ) ? $data['display_per_page'] : ( $data['post_limit'] ? $data['post_limit'] : get_option( 'posts_per_page' ) ); $hide = ( $query->max_num_pages < 2 ? " rt-hidden-elm" : null ); if ( $posts_loading_type == "pagination" ) { $htmlUtility .= Fns::rt_pagination( $query, $posts_per_page ); } else if ( rtTPG()->hasPro() && $posts_loading_type == "pagination_ajax" ) { //&& ! $isIsotope $htmlUtility .= "
"; } else if ( rtTPG()->hasPro() && $posts_loading_type == "load_more" ) { $load_more_button_text = $data['load_more_button_text'] ? $data['load_more_button_text'] : __( "Load More", 'the-post-grid' ); $htmlUtility .= "