* * @internal never define functions inside callbacks. * these functions could be run multiple times; this would result in a fatal error. * https://developer.wordpress.org/plugins/settings/custom-settings-page/ */ /** * custom option and settings */ if( ! function_exists('ofisuport_wpplugin_settings_init') ){ function ofisuport_wpplugin_settings_init() { // register a new setting for "ofisuport_wpplugin" page register_setting( 'ofisuport_wpplugin_settings', 'ofisuport_wpplugin_options' ); // register a new section in the "ofisuport_wpplugin" page add_settings_section( 'ofisuport_wpplugin_section_control_home', __( 'Home control.', 'ofisuport-wpplugin-textdomain' ), 'ofisuport_wpplugin_section_control_home_cb', 'ofisuport_wpplugin_settings' ); // register a new field in the "ofisuport_wpplugin_section_control_home" section, inside the "ofisuport_wpplugin" page // // uncoment below to activate // add_settings_field( // 'ofisuport_wpplugin_field_control_home', // as of WP 4.6 this value is used only internally // // use $args' label_for to populate the id inside the callback // __( 'This is the content being shown in home page:', 'ofisuport-wpplugin-textdomain' ), // 'ofisuport_wpplugin_field_control_home_cb', // 'ofisuport_wpplugin_settings', // 'ofisuport_wpplugin_section_control_home' // ); // register a new section in the "ofisuport_wpplugin" page // // uncoment below to activate // add_settings_section( // 'ofisuport_wpplugin_section_olderthandate', // __( 'Older than options.', 'ofisuport-wpplugin-textdomain' ), // 'ofisuport_wpplugin_section_olderthandate_cb', // 'ofisuport_wpplugin_settings' // ); // register a new field in the "ofisuport_wpplugin_section_olderthandate" section, inside the "ofisuport_wpplugin" page // // uncoment below to activate // add_settings_field( // 'ofisuport_wpplugin_field_olderthandate', // as of WP 4.6 this value is used only internally // // use $args' label_for to populate the id inside the callback // __( 'Hide content older than...', 'ofisuport-wpplugin-textdomain' ), // 'ofisuport_wpplugin_field_olderthandate_cb', // 'ofisuport_wpplugin_settings', // 'ofisuport_wpplugin_section_olderthandate', // [ // 'label_for' => 'ofisuport_wpplugin_field_olderthandate', // 'class' => 'ofisuport-wpplugin-row', // 'ofisuport_wpplugin_custom_data' => 'custom', // ] // ); } } /** * register our ofisuport_wpplugin_settings_init to the admin_init action hook */ add_action( 'admin_init', 'ofisuport_wpplugin_settings_init' ); /** * custom option and settings: * callback functions */ // olderthandate section cb // section callbacks can accept an $args parameter, which is an array. // $args have the following keys defined: title, id, callback. // the values are defined at the add_settings_section() function. if( ! function_exists('ofisuport_wpplugin_section_olderthandate_cb') ){ function ofisuport_wpplugin_section_olderthandate_cb( $args ) { ?>
. // the "class" key value is used for the "class" attribute of the
number of days from today to the past or the date from wich will be considered old posts. Then the class oldpost will be added to the post and pages so you can apply a css style to your theme.', 'ofisuport-wpplugin-textdomain' ); ?>