plugin_file = $plugin_file; } /** * Haakt aan. */ public function register(): void { add_action( 'admin_init', array( $this, 'register_setting' ) ); if ( '' !== $this->plugin_file ) { add_filter( 'plugin_action_links_' . plugin_basename( $this->plugin_file ), array( $this, 'action_links' ) ); } } /** * Meldt de optie, de sectie en het veld aan. */ public function register_setting(): void { register_setting( 'media', ApplyPolicy::OPTION, array( 'type' => 'string', 'sanitize_callback' => array( $this, 'sanitize' ), 'default' => ApplyPolicy::MODE_AUTO, 'show_in_rest' => false, ) ); // `before_section`/`after_section` bestaan sinds WordPress 6.1 en zijn // hier de enige manier om een anker te krijgen: do_settings_sections() // schrijft de
'; echo esc_html__( 'Yinga Focus can apply the focal point to your images automatically. It does that with object-position, which only affects images your theme already crops — an image that is fully visible now does not change.', 'yinga-focus' ); echo '
'; } /** * De drie radioknoppen. */ public function field(): void { $current = get_option( ApplyPolicy::OPTION, ApplyPolicy::MODE_AUTO ); if ( ! in_array( $current, ApplyPolicy::modes(), true ) ) { $current = ApplyPolicy::MODE_AUTO; } $options = array( ApplyPolicy::MODE_AUTO => array( __( 'Automatic', 'yinga-focus' ), __( 'Recommended. Every image with a focal point gets it applied.', 'yinga-focus' ), ), ApplyPolicy::MODE_PROPERTY => array( __( 'Make available only', 'yinga-focus' ), __( 'The plugin only sets the CSS variable --yf-pos. Your theme decides what to do with it.', 'yinga-focus' ), ), ApplyPolicy::MODE_OFF => array( __( 'Off', 'yinga-focus' ), __( 'The plugin leaves the front end alone. The focal data is kept and stays usable through the API.', 'yinga-focus' ), ), ); echo ''; } /** * Een link naar de instelling vanaf de pluginlijst. * * @param mixed $links De bestaande links. * @return mixed */ public function action_links( $links ) { if ( ! is_array( $links ) ) { return $links; } array_unshift( $links, sprintf( '%s', esc_url( admin_url( 'options-media.php#yinga_focus' ) ), esc_html__( 'Settings', 'yinga-focus' ) ) ); return $links; } }