@@ -8,93 +8,93 @@ |
||
| 8 | 8 | defined( 'ABSPATH' ) || exit; |
| 9 | 9 | |
| 10 | 10 | if ( ! function_exists( 'redux_social_profile_value_from_id' ) ) { |
| 11 | - /** |
|
| 12 | - * Returns social profile value from passed profile ID. |
|
| 13 | - * |
|
| 14 | - * @param string $opt_name Redux Framework opt_name. |
|
| 15 | - * @param string $id Profile ID. |
|
| 16 | - * @param string $value Social profile value to return (icon, name, class, background, color, url, or order). |
|
| 17 | - * |
|
| 18 | - * @return string Returns HTML string when $echo is set to false. Otherwise, true. |
|
| 19 | - * @since 1.0.0 |
|
| 20 | - * @access public |
|
| 21 | - */ |
|
| 22 | - function redux_social_profile_value_from_id( string $opt_name, string $id, string $value ): string { |
|
| 23 | - if ( empty( $opt_name ) || empty( $id ) || empty( $value ) ) { |
|
| 24 | - return ''; |
|
| 25 | - } |
|
| 26 | - |
|
| 27 | - $redux = ReduxFrameworkInstances::get_instance( $opt_name ); |
|
| 28 | - $social_profiles = $redux->extensions['social_profiles']; |
|
| 29 | - |
|
| 30 | - $redux_options = get_option( $social_profiles->opt_name ); |
|
| 31 | - $settings = $redux_options[ $social_profiles->field_id ]; |
|
| 32 | - |
|
| 33 | - foreach ( $settings as $arr ) { |
|
| 34 | - if ( $id === $arr['id'] ) { |
|
| 35 | - if ( $arr['enabled'] ) { |
|
| 36 | - if ( isset( $arr[ $value ] ) ) { |
|
| 37 | - return $arr[ $value ]; |
|
| 38 | - } |
|
| 39 | - } else { |
|
| 40 | - return ''; |
|
| 41 | - } |
|
| 42 | - } |
|
| 43 | - } |
|
| 44 | - |
|
| 45 | - return ''; |
|
| 46 | - } |
|
| 11 | + /** |
|
| 12 | + * Returns social profile value from passed profile ID. |
|
| 13 | + * |
|
| 14 | + * @param string $opt_name Redux Framework opt_name. |
|
| 15 | + * @param string $id Profile ID. |
|
| 16 | + * @param string $value Social profile value to return (icon, name, class, background, color, url, or order). |
|
| 17 | + * |
|
| 18 | + * @return string Returns HTML string when $echo is set to false. Otherwise, true. |
|
| 19 | + * @since 1.0.0 |
|
| 20 | + * @access public |
|
| 21 | + */ |
|
| 22 | + function redux_social_profile_value_from_id( string $opt_name, string $id, string $value ): string { |
|
| 23 | + if ( empty( $opt_name ) || empty( $id ) || empty( $value ) ) { |
|
| 24 | + return ''; |
|
| 25 | + } |
|
| 26 | + |
|
| 27 | + $redux = ReduxFrameworkInstances::get_instance( $opt_name ); |
|
| 28 | + $social_profiles = $redux->extensions['social_profiles']; |
|
| 29 | + |
|
| 30 | + $redux_options = get_option( $social_profiles->opt_name ); |
|
| 31 | + $settings = $redux_options[ $social_profiles->field_id ]; |
|
| 32 | + |
|
| 33 | + foreach ( $settings as $arr ) { |
|
| 34 | + if ( $id === $arr['id'] ) { |
|
| 35 | + if ( $arr['enabled'] ) { |
|
| 36 | + if ( isset( $arr[ $value ] ) ) { |
|
| 37 | + return $arr[ $value ]; |
|
| 38 | + } |
|
| 39 | + } else { |
|
| 40 | + return ''; |
|
| 41 | + } |
|
| 42 | + } |
|
| 43 | + } |
|
| 44 | + |
|
| 45 | + return ''; |
|
| 46 | + } |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | if ( ! function_exists( 'redux_render_icon_from_id' ) ) { |
| 50 | - /** |
|
| 51 | - * Renders social icon from passed profile ID. |
|
| 52 | - * |
|
| 53 | - * @param string $opt_name Redux Framework opt_name. |
|
| 54 | - * @param string $id Profile ID. |
|
| 55 | - * @param boolean $output Echos icon HTML when true. Returns icon HTML when false. |
|
| 56 | - * @param string $a_class Class name for a tag. |
|
| 57 | - * |
|
| 58 | - * @return string Returns HTML string when $echo is set to false. Otherwise, true. |
|
| 59 | - * @since 1.0.0 |
|
| 60 | - * @access public |
|
| 61 | - */ |
|
| 62 | - function redux_render_icon_from_id( string $opt_name, string $id, bool $output = true, string $a_class = '' ) { |
|
| 63 | - if ( empty( $opt_name ) || empty( $id ) ) { |
|
| 64 | - return ''; |
|
| 65 | - } |
|
| 66 | - |
|
| 67 | - include_once 'social_profiles/inc/class-redux-social-profiles-functions.php'; |
|
| 68 | - |
|
| 69 | - $redux = ReduxFrameworkInstances::get_instance( $opt_name ); |
|
| 70 | - $social_profiles = $redux->extensions['social_profiles']; |
|
| 71 | - |
|
| 72 | - $redux_options = get_option( $social_profiles->opt_name ); |
|
| 73 | - $settings = $redux_options[ $social_profiles->field_id ]; |
|
| 74 | - |
|
| 75 | - foreach ( $settings as $arr ) { |
|
| 76 | - if ( $id === $arr['id'] ) { |
|
| 77 | - if ( $arr['enabled'] ) { |
|
| 78 | - $arr['class'] = $arr['class'] ?? 'fa'; |
|
| 79 | - |
|
| 80 | - if ( $output ) { |
|
| 81 | - echo '<a class="' . esc_attr( $a_class ) . '" href="' . esc_url( $arr['url'] ) . '">'; |
|
| 82 | - Redux_Social_Profiles_Functions::render_icon( $arr['class'], $arr['icon'], $arr['color'], $arr['background'], '' ); |
|
| 83 | - echo '</a>'; |
|
| 84 | - |
|
| 85 | - return true; |
|
| 86 | - } else { |
|
| 87 | - $html = '<a class="' . $a_class . '"href="' . $arr['url'] . '">'; |
|
| 88 | - |
|
| 89 | - $html .= Redux_Social_Profiles_Functions::render_icon( $arr['class'], $arr['icon'], $arr['color'], $arr['background'], '', false ); |
|
| 90 | - $html .= '</a>'; |
|
| 91 | - |
|
| 92 | - return $html; |
|
| 93 | - } |
|
| 94 | - } |
|
| 95 | - } |
|
| 96 | - } |
|
| 97 | - |
|
| 98 | - return ''; |
|
| 99 | - } |
|
| 50 | + /** |
|
| 51 | + * Renders social icon from passed profile ID. |
|
| 52 | + * |
|
| 53 | + * @param string $opt_name Redux Framework opt_name. |
|
| 54 | + * @param string $id Profile ID. |
|
| 55 | + * @param boolean $output Echos icon HTML when true. Returns icon HTML when false. |
|
| 56 | + * @param string $a_class Class name for a tag. |
|
| 57 | + * |
|
| 58 | + * @return string Returns HTML string when $echo is set to false. Otherwise, true. |
|
| 59 | + * @since 1.0.0 |
|
| 60 | + * @access public |
|
| 61 | + */ |
|
| 62 | + function redux_render_icon_from_id( string $opt_name, string $id, bool $output = true, string $a_class = '' ) { |
|
| 63 | + if ( empty( $opt_name ) || empty( $id ) ) { |
|
| 64 | + return ''; |
|
| 65 | + } |
|
| 66 | + |
|
| 67 | + include_once 'social_profiles/inc/class-redux-social-profiles-functions.php'; |
|
| 68 | + |
|
| 69 | + $redux = ReduxFrameworkInstances::get_instance( $opt_name ); |
|
| 70 | + $social_profiles = $redux->extensions['social_profiles']; |
|
| 71 | + |
|
| 72 | + $redux_options = get_option( $social_profiles->opt_name ); |
|
| 73 | + $settings = $redux_options[ $social_profiles->field_id ]; |
|
| 74 | + |
|
| 75 | + foreach ( $settings as $arr ) { |
|
| 76 | + if ( $id === $arr['id'] ) { |
|
| 77 | + if ( $arr['enabled'] ) { |
|
| 78 | + $arr['class'] = $arr['class'] ?? 'fa'; |
|
| 79 | + |
|
| 80 | + if ( $output ) { |
|
| 81 | + echo '<a class="' . esc_attr( $a_class ) . '" href="' . esc_url( $arr['url'] ) . '">'; |
|
| 82 | + Redux_Social_Profiles_Functions::render_icon( $arr['class'], $arr['icon'], $arr['color'], $arr['background'], '' ); |
|
| 83 | + echo '</a>'; |
|
| 84 | + |
|
| 85 | + return true; |
|
| 86 | + } else { |
|
| 87 | + $html = '<a class="' . $a_class . '"href="' . $arr['url'] . '">'; |
|
| 88 | + |
|
| 89 | + $html .= Redux_Social_Profiles_Functions::render_icon( $arr['class'], $arr['icon'], $arr['color'], $arr['background'], '', false ); |
|
| 90 | + $html .= '</a>'; |
|
| 91 | + |
|
| 92 | + return $html; |
|
| 93 | + } |
|
| 94 | + } |
|
| 95 | + } |
|
| 96 | + } |
|
| 97 | + |
|
| 98 | + return ''; |
|
| 99 | + } |
|
| 100 | 100 | } |