* * @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('xarxaprod_wpplugin_settings_init') ){ function xarxaprod_wpplugin_settings_init() { // register a new setting for "xarxaprod_wpplugin" page register_setting( 'xarxaprod_wpplugin_settings', 'xarxaprod_wpplugin_options' ); // register a new section in the "xarxaprod_wpplugin" page add_settings_section( 'xarxaprod_wpplugin_section_control_home', __( 'Home control.', 'xarxaprod-wpplugin-textdomain' ), 'xarxaprod_wpplugin_section_control_home_cb', 'xarxaprod_wpplugin_settings' ); // register a new field in the "xarxaprod_wpplugin_section_control_home" section, inside the "xarxaprod_wpplugin" page // // uncoment below to activate // add_settings_field( // 'xarxaprod_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:', 'xarxaprod-wpplugin-textdomain' ), // 'xarxaprod_wpplugin_field_control_home_cb', // 'xarxaprod_wpplugin_settings', // 'xarxaprod_wpplugin_section_control_home' // ); // register a new section in the "xarxaprod_wpplugin" page add_settings_section( 'xarxaprod_wpplugin_section_reusableblocks', __( 'Reusable blocks.', 'xarxaprod-wpplugin-textdomain' ), 'xarxaprod_wpplugin_section_reusableblocks_cb', 'xarxaprod_wpplugin_reusableblocks' ); // register a new field in the "xarxaprod_wpplugin_section_reusableblocks" section, inside the "xarxaprod_wpplugin" page // // uncoment below to activate add_settings_field( 'xarxaprod_wpplugin_field_reusableblocks', // as of WP 4.6 this value is used only internally // use $args' label_for to populate the id inside the callback __( 'Follow this link to edit the reusable blocks Reusable blocks', 'xarxaprod-wpplugin-textdomain' ), 'xarxaprod_wpplugin_field_reusableblocks_cb', 'xarxaprod_wpplugin_settings', 'xarxaprod_wpplugin_section_reusableblocks', // edit.php?post_type=wp_block ); // register a new section in the "xarxaprod_wpplugin" page // // uncoment below to activate // add_settings_section( // 'xarxaprod_wpplugin_section_olderthandate', // __( 'Older than options.', 'xarxaprod-wpplugin-textdomain' ), // 'xarxaprod_wpplugin_section_olderthandate_cb', // 'xarxaprod_wpplugin_settings' // ); // register a new field in the "xarxaprod_wpplugin_section_olderthandate" section, inside the "xarxaprod_wpplugin" page // // uncoment below to activate // add_settings_field( // 'xarxaprod_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...', 'xarxaprod-wpplugin-textdomain' ), // 'xarxaprod_wpplugin_field_olderthandate_cb', // 'xarxaprod_wpplugin_settings', // 'xarxaprod_wpplugin_section_olderthandate', // [ // 'label_for' => 'xarxaprod_wpplugin_field_olderthandate', // 'class' => 'xarxaprod-wpplugin-row', // 'xarxaprod_wpplugin_custom_data' => 'custom', // ] // ); } } /** * register our xarxaprod_wpplugin_settings_init to the admin_init action hook */ add_action( 'admin_init', 'xarxaprod_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('xarxaprod_wpplugin_section_olderthandate_cb') ){ function xarxaprod_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.', 'xarxaprod-wpplugin-textdomain' ); ?>