'page', 'post_status' => array( 'publish', 'private' ), 'posts_per_page' => 20, 'no_found_rows' => true, 'meta_key' => '_wp_page_template', 'meta_value' => $template, 'orderby' => array( 'menu_order' => 'ASC', 'ID' => 'ASC', ), ) ); $match = null; if ( $query->have_posts() ) { foreach ( $query->posts as $page ) { if ( $preferred_slug && $preferred_slug === $page->post_name ) { $match = $page; break; } if ( ! $match ) { $match = $page; } } } wp_reset_postdata(); if ( $match ) { return get_permalink( $match->ID ); } $path_candidates = array(); if ( $preferred_slug ) { $path_candidates[] = 'slide-dashboard/' . $preferred_slug; $path_candidates[] = $preferred_slug; } if ( $fallback_path ) { $path_candidates[] = trim( $fallback_path, '/' ); } foreach ( array_unique( $path_candidates ) as $path ) { $page = get_page_by_path( $path ); if ( $page ) { return get_permalink( $page->ID ); } } return $fallback_path ? home_url( $fallback_path ) : ''; } // Include core files require_once HSSM_PLUGIN_DIR . 'includes/class-hssm-autoloader.php'; require_once HSSM_PLUGIN_DIR . 'includes/class-hssm-main.php'; /** * Initialize the Hi-School Slide Manager plugin * * @since 1.0.0 */ function hssm_init() { // Check if we're on the main site (this plugin should only run on main site) if ( is_multisite() && ! is_main_site() ) { return; } // Initialize autoloader HSSM_Autoloader::init(); // Get the main plugin instance and initialize $hssm = HSSM_Main::get_instance(); $hssm->init(); } // Hook into WordPress add_action( 'plugins_loaded', 'hssm_init' ); // Activation and deactivation hooks register_activation_hook( __FILE__, array( 'HSSM_Main', 'activate' ) ); register_deactivation_hook( __FILE__, array( 'HSSM_Main', 'deactivate' ) ); register_uninstall_hook( __FILE__, array( 'HSSM_Main', 'uninstall' ) );