render_map( $map_type_slug, $args ) : ''; } // Dark/auto colour scheme itself is PRO (Mapfield_Spots_Pro\Dark_Mode, its // own admin_body_class/admin_head hooks + dark-mode.css) — this plugin only // adds the base scoping class every admin screen of ours needs regardless. add_filter( 'admin_body_class', function ( $classes ) { $screen = get_current_screen(); if ( ! $screen ) { return $classes; } $is_own_page = strpos( $screen->id, 'mapfield-spots' ) !== false; $is_own_cpt = $screen->post_type && strpos( $screen->post_type, Mapfield_Spots\CPT::PREFIX ) === 0; if ( $is_own_page || $is_own_cpt ) { $classes .= ' plugin-mapfield-spots'; } return $classes; } ); add_action( 'plugins_loaded', function () { // No load_plugin_textdomain(): WP 4.6+ auto-loads translations by slug. // One-time repair: replaces a leftover MapLibre demo style (or a style // URL wiped empty by 1.3.1's esc_url_raw() bug) with the real default. $style_option = get_option( Mapfield_Spots\Settings::OPTION_STYLE ); if ( '' === $style_option || 'https://demotiles.maplibre.org/style.json' === $style_option ) { update_option( Mapfield_Spots\Settings::OPTION_STYLE, 'mapbox://styles/mapbox/streets-v12' ); } new Mapfield_Spots\Settings(); new Mapfield_Spots\Map_Types_Admin(); new Mapfield_Spots\CPT(); new Mapfield_Spots\Location_Field(); new Mapfield_Spots\Content_Fields(); new Mapfield_Spots\Contact_Fields(); new Mapfield_Spots\Gallery_Field(); new Mapfield_Spots\Hours_Field(); new Mapfield_Spots\Social_Field(); new Mapfield_Spots\Rating_Field(); new Mapfield_Spots\Admin_Columns(); new Mapfield_Spots\Frontend(); new Mapfield_Spots\Dashboard_Widget(); } ); register_activation_hook( __FILE__, function () { update_option( 'mapfield_spots_flush_rewrite', 1 ); // Consumed by Settings::maybe_redirect_after_activation() to prompt for a Mapbox token. update_option( 'mapfield_spots_activation_redirect', 1 ); } ); add_action( 'init', function () { if ( get_option( 'mapfield_spots_flush_rewrite' ) ) { flush_rewrite_rules(); delete_option( 'mapfield_spots_flush_rewrite' ); } }, 999 ); // Registered (not enqueued) on 'init' so admin.css/frontend.css can each // declare it as a dependency instead of enqueueing it separately. add_action( 'init', function () { wp_register_style( 'mapfield-spots-palette', MAPFIELD_SPOTS_URL . 'assets/palette.css', array(), MAPFIELD_SPOTS_VERSION ); } ); register_deactivation_hook( __FILE__, function () { flush_rewrite_rules(); } ); // ── Plugins list row actions ───────────────────────────────────────────── // Adds a "Settings" link next to Deactivate on the Plugins admin page. add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), function ( $links ) { $settings_url = admin_url( 'options-general.php?page=mapfield-spots-settings' ); $settings_link = '' . esc_html__( 'Settings', 'mapfield-spots' ) . ''; return array_merge( $links, array( 'settings' => $settings_link ) ); } );