/** * Update Options Array * @since 1.0 */ public function update_options() { // If this is not the plugin settings page, bail if (!isset($_GET['page']) || 'fb_pxl_options' !== $_GET['page']) { return; } $options = get_option('fb_pxl_options'); $post_types = get_post_types(); // Remove any options that don't have a corresponding post type if ($options) { foreach ($options as $option_key => $option_value) { if (!array_key_exists($option_key, $post_types)) { unset($options[$option_key]); } } } // Add any post types missing from the options array foreach ($post_types as $post_type) { if (!array_key_exists($post_type, $options)) { $options[$post_type] = ''; } } // Save changes to the options array self::$fb_pxl_options = $options; update_option('fb_pxl_options', $options); }
/** * Update Options Array * @since 1.0 */ public function update_options() { $options = get_option('fb_pxl_options'); $post_types = get_post_types(); // Remove any options that don't have a corresponding post type if ($options) { foreach ($options as $option_key => $option_value) { if (!array_key_exists($option_key, $post_types)) { unset($options[$option_key]); } } } // Add any post types missing from the options array foreach ($post_types as $post_type) { if (!array_key_exists($post_type, $options)) { $options[$post_type] = ''; } } // Save changes to the options array self::$fb_pxl_options = $options; update_option('fb_pxl_options', $options); }