self::COMP_SOCIAL, self::COMP_SITEMAP, self::COMP_HEALTH, self::COMP_LIGHTHOUSE, self::COMP_ROBOTS, self::COMP_BREADCRUMBS, ); } /** * Gets component-specific options * * @param string $options_key Specific options key we're after. * @param mixed $default_value Default value. * * @return mixed Options */ public static function get_specific_options( $options_key, $default_value = array() ) { if ( empty( $options_key ) ) { return $default_value; } return get_option( $options_key, $default_value ); } /** * Updates component-specific options * * @param string $component One of the known components (use class constants pl0x). * @param array $options Specific options we want to save. */ public static function update_component_options( $component, $options ) { if ( empty( $component ) ) { return array(); } if ( ! in_array( $component, self::get_all_components(), true ) ) { return array(); } $options_key = "wds_{$component}_options"; return self::update_specific_options( $options_key, $options ); } /** * Updates component-specific options * * @param string $option_key Specific options key we're after. * @param mixed $options Specific options we want to save. */ public static function update_specific_options( $option_key, $options ) { $old_values = self::get_specific_options( $option_key ); $updated = update_option( $option_key, $options ); if ( $updated ) { /** * Action hook to trigger after updating specific options. * * @param array $options Option value. * @param array $old_values Old values. * @param string $option_key Updated option key. */ do_action( 'smartcrawl_after_update_specific_options', $options, $old_values, $option_key ); } return $updated; } /** * Deletes component options. * * @param string $component Component key. * * @return array|bool */ public static function delete_component_options( $component ) { if ( empty( $component ) ) { return array(); } if ( ! in_array( $component, self::get_all_components(), true ) ) { return array(); } $options_key = "wds_{$component}_options"; return self::delete_specific_options( $options_key ); } /** * Deletes a specific option by key. * * @param string $option_key Option key. * * @return bool */ public static function delete_specific_options( $option_key ) { return delete_option( $option_key ); } /** * Deactivates a component. * * @param string $component Component name. * * @return void */ public static function deactivate_component( $component ) { $options = self::get_specific_options( 'wds_settings_options' ); $options[ $component ] = 0; self::update_specific_options( 'wds_settings_options', $options ); } /** * Returns known components, as component => title pairs * * @return array Known components */ public static function get_known_components() { return array( self::COMP_ONPAGE => __( 'Title & Meta Optimization', 'wds' ), self::COMP_SOCIAL => __( 'Social', 'wds' ), self::COMP_SITEMAP => __( 'XML Sitemap', 'wds' ), ); } /** * Retrieves the current locale. * * @return string */ public static function get_locale() { return get_locale(); } /** * Get a key value from the values provided. * * @param string $key Key. * @param array $values Array of values. * @param mixed $default_value Default value. * * @return false|mixed * * @since 3.7.0 */ public static function get_value( $key, $values = array(), $default_value = false ) { return isset( $values[ $key ] ) ? $values[ $key ] : $default_value; } }