id = $id; $this->settings = $settings; add_action( 'admin_enqueue_scripts', array( $this, 'enqueue' ) ); } /** * Determine if a control should be visible or not. * * @return bool */ public function should_add_control() { if ( ! array_key_exists( 'active_callback', $this->settings ) ) { return true; } $object = $this->settings['active_callback'][0]; $method = $this->settings['active_callback'][1]; if ( method_exists( $object, $method ) ) { return $object->$method(); } return true; } /** * Enqueue scripts and styles */ public function enqueue() { wp_enqueue_script( 'hestia-meta-radio-buttons-script', get_template_directory_uri() . '/inc/admin/page-settings/meta-radio-buttons/script.js', array( 'jquery', 'jquery-ui-button' ), HESTIA_VERSION, true ); wp_enqueue_style( 'hestia-meta-radio-buttons-style', get_template_directory_uri() . '/inc/admin/page-settings/meta-radio-buttons/style.css', array(), HESTIA_VERSION ); } /** * Render controls content * * @return void */ public function render_content() { if ( empty( $this->id ) ) { return; } if ( empty( $this->settings ) ) { return; } if ( ! array_key_exists( 'choices', $this->settings ) ) { return; } global $post; wp_nonce_field( 'hestia_individual_layout_nonce', 'individual_layout_nonce' ); echo $this->get_control_content( $post->ID ); } /** * Render control label. * * @return string */ private function render_label() { $control_label = ''; $label = array_key_exists( 'label', $this->settings ) ? $this->settings['label'] : ''; if ( ! empty( $label ) ) { $control_label .= '
'; $control_label .= '' . esc_html( $label ) . ''; $control_label .= '
'; } return $control_label; } /** * Render default button. * * @return string */ private function render_default_button( $pid ) { $default_button = ''; $class_to_add = 'button button-secondary reset-data'; $value = $this->get_control_value( $pid ); if ( empty( $value ) || $value === 'default' ) { $class_to_add .= ' disabled'; } $default_button .= '