WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru Получай пассивный доход от сайта с помощью браузерных PUSH уведомлений

Carbon fields поля select не сохраняется

Добры день ребята я использую версию 3.1.20 в виде плагина, все поля работают нормально кроме select оно правильно показывает в админке но не сохраняет в базе, подскажете правильны подход вот мой класс

version = STRIDES_CATEGORY_SLIDER_VERSION;
		} else {
			$this->version = '1.0.0';
		}
		$this->plugin_name = 'strides-category-slider';

		$this->load_dependencies();
		$this->set_locale();
		$this->define_admin_hooks();
		$this->define_public_hooks();

		add_action('carbon_fields_register_fields', array($this, 'strides_get_products_for_tab'));

		add_action('carbon_fields_register_fields', array($this, 'strides_get_products'));
	}

// Создаем контейнер для полях
	public function strides_get_products()
	{

		Container::make('term_meta', 'Slider Category Properties')
			->show_on_taxonomy('product_cat')
			->add_fields(array(
				Field::make('text','strides_category_title','Title for Category'),
				Field::make('image','strides_category_background','Background for Category')
				->set_value_type('url'),
				Field::make('image','strides_category_icon','Icon for Category')
				->set_value_type('url'),
				Field::make('select', 'strides_category_prodct_id', 'Product For Slider 1')
					->add_options(array($this, 'strides_get_products_for_tab')),
					// ->add_options( array(1=> 'one', 2=> 'two', 3=> 'four') ),
			));
	}

// получаем все продукты данного категории по ид категории
	public function strides_get_products_for_tab()
	{
		$args = array(
			'post_type' => 'product',
			'numberposts' => 300,
			'tax_query' => array(
				'relation' => 'OR',
				array(
					'taxonomy' => 'product_cat',
					'field' => 'id',
					'terms' => $_GET['tag_ID'],
				),
			),
		);
		$products = get_posts($args);
		$prod[0] = 'Do not choose';
		if (!empty($products)) {
			foreach ($products as $product) {
				$prod[$product->ID] = $product->post_title;
			}
		}
		$this->slide_products = $prod;

		return $prod;
	}

	/**
	 * Load the required dependencies for this plugin.
	 *
	 * Include the following files that make up the plugin:
	 *
	 * - Strides_Category_Slider_Loader. Orchestrates the hooks of the plugin.
	 * - Strides_Category_Slider_i18n. Defines internationalization functionality.
	 * - Strides_Category_Slider_Admin. Defines all hooks for the admin area.
	 * - Strides_Category_Slider_Public. Defines all hooks for the public side of the site.
	 *
	 * Create an instance of the loader which will be used to register the hooks
	 * with WordPress.
	 *
	 * @since    1.0.0
	 * @access   private
	 */
	private function load_dependencies()
	{

		/**
		 * The class responsible for orchestrating the actions and filters of the
		 * core plugin.
		 */
		require_once plugin_dir_path(dirname(__FILE__)) . 'includes/class-strides-category-slider-loader.php';

		/**
		 * The class responsible for defining internationalization functionality
		 * of the plugin.
		 */
		require_once plugin_dir_path(dirname(__FILE__)) . 'includes/class-strides-category-slider-i18n.php';

		/**
		 * The class responsible for defining all actions that occur in the admin area.
		 */
		require_once plugin_dir_path(dirname(__FILE__)) . 'admin/class-strides-category-slider-admin.php';

		/**
		 * The class responsible for defining all actions that occur in the public-facing
		 * side of the site.
		 */
		require_once plugin_dir_path(dirname(__FILE__)) . 'public/class-strides-category-slider-public.php';

		$this->loader = new Strides_Category_Slider_Loader();

	}

	/**
	 * Define the locale for this plugin for internationalization.
	 *
	 * Uses the Strides_Category_Slider_i18n class in order to set the domain and to register the hook
	 * with WordPress.
	 *
	 * @since    1.0.0
	 * @access   private
	 */
	private function set_locale()
	{

		$plugin_i18n = new Strides_Category_Slider_i18n();

		$this->loader->add_action('plugins_loaded', $plugin_i18n, 'load_plugin_textdomain');

	}

	/**
	 * Register all of the hooks related to the admin area functionality
	 * of the plugin.
	 *
	 * @since    1.0.0
	 * @access   private
	 */
	private function define_admin_hooks()
	{

		$plugin_admin = new Strides_Category_Slider_Admin($this->get_plugin_name(), $this->get_version());
		$this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_styles');
		$this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts');

	}

	/**
	 * Register all of the hooks related to the public-facing functionality
	 * of the plugin.
	 *
	 * @since    1.0.0
	 * @access   private
	 */
	private function define_public_hooks()
	{

		$plugin_public = new Strides_Category_Slider_Public($this->get_plugin_name(), $this->get_version());

		$this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_styles');
		$this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_scripts');

	}

	/**
	 * Run the loader to execute all of the hooks with WordPress.
	 *
	 * @since    1.0.0
	 */
	public function run()
	{
		$this->loader->run();
	}

	/**
	 * The name of the plugin used to uniquely identify it within the context of
	 * WordPress and to define internationalization functionality.
	 *
	 * @since     1.0.0
	 * @return    string    The name of the plugin.
	 */
	public function get_plugin_name()
	{
		return $this->plugin_name;
	}

	/**
	 * The reference to the class that orchestrates the hooks with the plugin.
	 *
	 * @since     1.0.0
	 * @return    Strides_Category_Slider_Loader    Orchestrates the hooks of the plugin.
	 */
	public function get_loader()
	{
		return $this->loader;
	}

	/**
	 * Retrieve the version number of the plugin.
	 *
	 * @since     1.0.0
	 * @return    string    The version number of the plugin.
	 */
	public function get_version()
	{
		return $this->version;
	}

}
0
Hovo
6 месяцев назад

Нет ответов на этот вопрос.

    На вопросы могут отвечать только зарегистрированные пользователи. Вход . Регистрация