Current Path : /storage/v11800/affypharma/public_html/wp-content/plugins/smart-custom-fields/classes/controller/ |
Linux v11800 5.3.0-1023-aws #25~18.04.1-Ubuntu SMP Fri Jun 5 15:19:18 UTC 2020 aarch64
|
Current File : /storage/v11800/affypharma/public_html/wp-content/plugins/smart-custom-fields/classes/controller/class.option.php |
<?php
/**
* @package smart-custom-fields
* @author inc2734
* @license GPL-2.0+
*/
/**
* Smart_Custom_Fields_Controller_Option class.
*/
class Smart_Custom_Fields_Controller_Option extends Smart_Custom_Fields_Controller_Base {
/**
* __construct
*/
public function __construct() {
parent::__construct();
add_action( SCF_Config::PREFIX . 'custom-options-page', array( $this, 'save_option' ) );
add_action( SCF_Config::PREFIX . 'custom-options-page', array( $this, 'custom_options_page' ) );
}
/**
* Loading resources for term edit page.
*
* @param string $hook The current admin page.
*/
public function admin_enqueue_scripts( $hook ) {
parent::admin_enqueue_scripts( $hook );
wp_enqueue_style(
SCF_Config::PREFIX . 'option',
SMART_CUSTOM_FIELDS_URL . '/css/option.css',
array(),
filemtime( SMART_CUSTOM_FIELDS_PATH . '/css/option.css' )
);
}
/**
* Displaying custom fields in custom options page.
*
* @param stdClass $option Option object.
*/
public function custom_options_page( $option ) {
$settings = SCF::get_settings( $option );
if ( ! $settings ) {
return;
}
$callback_args = array();
?>
<form method="post" action="">
<?php foreach ( $settings as $setting ) : ?>
<?php $callback_args['args'] = $setting->get_groups(); ?>
<table class="form-table">
<tr>
<th scope="row"><?php echo esc_html( $setting->get_title() ); ?></th>
<td><?php $this->display_meta_box( $option, $callback_args ); ?></td>
</tr>
</table>
<?php endforeach; ?>
<p class="submit">
<input type="submit" name="submit" id="submit" class="button button-primary" value="<?php esc_attr_e( 'Save settings', 'smart-custom-fields' ); ?>">
</p>
</form>
<?php
}
/**
* Saving meta data from custom fields in custom options page.
*
* @param stdClass $option Option object.
*/
public function save_option( $option ) {
if ( ! filter_input( INPUT_POST, SCF_Config::NAME, FILTER_DEFAULT, FILTER_REQUIRE_ARRAY ) ) {
return;
}
$this->save( filter_input_array( INPUT_POST ), $option );
}
}