@@ -868,322 +868,322 @@ discard block |
||
868 | 868 | } |
869 | 869 | |
870 | 870 | function wpinv_get_pages( $with_slug = false, $default_label = NULL ) { |
871 | - $pages_options = array(); |
|
871 | + $pages_options = array(); |
|
872 | 872 | |
873 | - if( $default_label !== NULL && $default_label !== false ) { |
|
874 | - $pages_options = array( '' => $default_label ); // Blank option |
|
875 | - } |
|
873 | + if( $default_label !== NULL && $default_label !== false ) { |
|
874 | + $pages_options = array( '' => $default_label ); // Blank option |
|
875 | + } |
|
876 | 876 | |
877 | - $pages = get_pages(); |
|
878 | - if ( $pages ) { |
|
879 | - foreach ( $pages as $page ) { |
|
880 | - $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title; |
|
877 | + $pages = get_pages(); |
|
878 | + if ( $pages ) { |
|
879 | + foreach ( $pages as $page ) { |
|
880 | + $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title; |
|
881 | 881 | $pages_options[ $page->ID ] = $title; |
882 | - } |
|
883 | - } |
|
882 | + } |
|
883 | + } |
|
884 | 884 | |
885 | - return $pages_options; |
|
885 | + return $pages_options; |
|
886 | 886 | } |
887 | 887 | |
888 | 888 | function wpinv_header_callback( $args ) { |
889 | - if ( !empty( $args['desc'] ) ) { |
|
889 | + if ( !empty( $args['desc'] ) ) { |
|
890 | 890 | echo $args['desc']; |
891 | 891 | } |
892 | 892 | } |
893 | 893 | |
894 | 894 | function wpinv_hidden_callback( $args ) { |
895 | - global $wpinv_options; |
|
896 | - |
|
897 | - if ( isset( $args['set_value'] ) ) { |
|
898 | - $value = $args['set_value']; |
|
899 | - } elseif ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
900 | - $value = $wpinv_options[ $args['id'] ]; |
|
901 | - } else { |
|
902 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
903 | - } |
|
904 | - |
|
905 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
906 | - $args['readonly'] = true; |
|
907 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
908 | - $name = ''; |
|
909 | - } else { |
|
910 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
911 | - } |
|
912 | - |
|
913 | - $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />'; |
|
895 | + global $wpinv_options; |
|
896 | + |
|
897 | + if ( isset( $args['set_value'] ) ) { |
|
898 | + $value = $args['set_value']; |
|
899 | + } elseif ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
900 | + $value = $wpinv_options[ $args['id'] ]; |
|
901 | + } else { |
|
902 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
903 | + } |
|
904 | + |
|
905 | + if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
906 | + $args['readonly'] = true; |
|
907 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
908 | + $name = ''; |
|
909 | + } else { |
|
910 | + $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
911 | + } |
|
912 | + |
|
913 | + $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />'; |
|
914 | 914 | |
915 | - echo $html; |
|
915 | + echo $html; |
|
916 | 916 | } |
917 | 917 | |
918 | 918 | function wpinv_checkbox_callback( $args ) { |
919 | - global $wpinv_options; |
|
919 | + global $wpinv_options; |
|
920 | 920 | |
921 | 921 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
922 | 922 | |
923 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
924 | - $name = ''; |
|
925 | - } else { |
|
926 | - $name = 'name="wpinv_settings[' . $sanitize_id . ']"'; |
|
927 | - } |
|
923 | + if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
924 | + $name = ''; |
|
925 | + } else { |
|
926 | + $name = 'name="wpinv_settings[' . $sanitize_id . ']"'; |
|
927 | + } |
|
928 | 928 | |
929 | - $checked = isset( $wpinv_options[ $args['id'] ] ) ? checked( 1, $wpinv_options[ $args['id'] ], false ) : ''; |
|
930 | - $html = '<input type="checkbox" id="wpinv_settings[' . $sanitize_id . ']"' . $name . ' value="1" ' . $checked . '/>'; |
|
931 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
929 | + $checked = isset( $wpinv_options[ $args['id'] ] ) ? checked( 1, $wpinv_options[ $args['id'] ], false ) : ''; |
|
930 | + $html = '<input type="checkbox" id="wpinv_settings[' . $sanitize_id . ']"' . $name . ' value="1" ' . $checked . '/>'; |
|
931 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
932 | 932 | |
933 | - echo $html; |
|
933 | + echo $html; |
|
934 | 934 | } |
935 | 935 | |
936 | 936 | function wpinv_multicheck_callback( $args ) { |
937 | - global $wpinv_options; |
|
937 | + global $wpinv_options; |
|
938 | 938 | |
939 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
939 | + $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
940 | 940 | |
941 | - if ( ! empty( $args['options'] ) ) { |
|
942 | - foreach( $args['options'] as $key => $option ): |
|
943 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
944 | - if ( isset( $wpinv_options[$args['id']][$sanitize_key] ) ) { |
|
945 | - $enabled = $sanitize_key; |
|
946 | - } else { |
|
947 | - $enabled = NULL; |
|
948 | - } |
|
949 | - echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/> '; |
|
950 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label><br/>'; |
|
951 | - endforeach; |
|
952 | - echo '<p class="description">' . $args['desc'] . '</p>'; |
|
953 | - } |
|
941 | + if ( ! empty( $args['options'] ) ) { |
|
942 | + foreach( $args['options'] as $key => $option ): |
|
943 | + $sanitize_key = wpinv_sanitize_key( $key ); |
|
944 | + if ( isset( $wpinv_options[$args['id']][$sanitize_key] ) ) { |
|
945 | + $enabled = $sanitize_key; |
|
946 | + } else { |
|
947 | + $enabled = NULL; |
|
948 | + } |
|
949 | + echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/> '; |
|
950 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label><br/>'; |
|
951 | + endforeach; |
|
952 | + echo '<p class="description">' . $args['desc'] . '</p>'; |
|
953 | + } |
|
954 | 954 | } |
955 | 955 | |
956 | 956 | function wpinv_payment_icons_callback( $args ) { |
957 | - global $wpinv_options; |
|
957 | + global $wpinv_options; |
|
958 | 958 | |
959 | 959 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
960 | 960 | |
961 | - if ( ! empty( $args['options'] ) ) { |
|
962 | - foreach( $args['options'] as $key => $option ) { |
|
961 | + if ( ! empty( $args['options'] ) ) { |
|
962 | + foreach( $args['options'] as $key => $option ) { |
|
963 | 963 | $sanitize_key = wpinv_sanitize_key( $key ); |
964 | 964 | |
965 | - if( isset( $wpinv_options[$args['id']][$key] ) ) { |
|
966 | - $enabled = $option; |
|
967 | - } else { |
|
968 | - $enabled = NULL; |
|
969 | - } |
|
970 | - |
|
971 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">'; |
|
972 | - |
|
973 | - echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/> '; |
|
974 | - |
|
975 | - if ( wpinv_string_is_image_url( $key ) ) { |
|
976 | - echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
977 | - } else { |
|
978 | - $card = strtolower( str_replace( ' ', '', $option ) ); |
|
979 | - |
|
980 | - if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) { |
|
981 | - $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' ); |
|
982 | - } else { |
|
983 | - $image = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false ); |
|
984 | - $content_dir = WP_CONTENT_DIR; |
|
985 | - |
|
986 | - if ( function_exists( 'wp_normalize_path' ) ) { |
|
987 | - // Replaces backslashes with forward slashes for Windows systems |
|
988 | - $image = wp_normalize_path( $image ); |
|
989 | - $content_dir = wp_normalize_path( $content_dir ); |
|
990 | - } |
|
991 | - |
|
992 | - $image = str_replace( $content_dir, content_url(), $image ); |
|
993 | - } |
|
994 | - |
|
995 | - echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
996 | - } |
|
997 | - echo $option . '</label>'; |
|
998 | - } |
|
999 | - echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
1000 | - } |
|
965 | + if( isset( $wpinv_options[$args['id']][$key] ) ) { |
|
966 | + $enabled = $option; |
|
967 | + } else { |
|
968 | + $enabled = NULL; |
|
969 | + } |
|
970 | + |
|
971 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">'; |
|
972 | + |
|
973 | + echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/> '; |
|
974 | + |
|
975 | + if ( wpinv_string_is_image_url( $key ) ) { |
|
976 | + echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
977 | + } else { |
|
978 | + $card = strtolower( str_replace( ' ', '', $option ) ); |
|
979 | + |
|
980 | + if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) { |
|
981 | + $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' ); |
|
982 | + } else { |
|
983 | + $image = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false ); |
|
984 | + $content_dir = WP_CONTENT_DIR; |
|
985 | + |
|
986 | + if ( function_exists( 'wp_normalize_path' ) ) { |
|
987 | + // Replaces backslashes with forward slashes for Windows systems |
|
988 | + $image = wp_normalize_path( $image ); |
|
989 | + $content_dir = wp_normalize_path( $content_dir ); |
|
990 | + } |
|
991 | + |
|
992 | + $image = str_replace( $content_dir, content_url(), $image ); |
|
993 | + } |
|
994 | + |
|
995 | + echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
996 | + } |
|
997 | + echo $option . '</label>'; |
|
998 | + } |
|
999 | + echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
1000 | + } |
|
1001 | 1001 | } |
1002 | 1002 | |
1003 | 1003 | function wpinv_radio_callback( $args ) { |
1004 | - global $wpinv_options; |
|
1004 | + global $wpinv_options; |
|
1005 | 1005 | |
1006 | 1006 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
1007 | 1007 | |
1008 | 1008 | foreach ( $args['options'] as $key => $option ) : |
1009 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
1009 | + $sanitize_key = wpinv_sanitize_key( $key ); |
|
1010 | 1010 | |
1011 | 1011 | $checked = false; |
1012 | 1012 | |
1013 | - if ( isset( $wpinv_options[ $args['id'] ] ) && $wpinv_options[ $args['id'] ] == $key ) |
|
1014 | - $checked = true; |
|
1015 | - elseif( isset( $args['std'] ) && $args['std'] == $key && ! isset( $wpinv_options[ $args['id'] ] ) ) |
|
1016 | - $checked = true; |
|
1013 | + if ( isset( $wpinv_options[ $args['id'] ] ) && $wpinv_options[ $args['id'] ] == $key ) |
|
1014 | + $checked = true; |
|
1015 | + elseif( isset( $args['std'] ) && $args['std'] == $key && ! isset( $wpinv_options[ $args['id'] ] ) ) |
|
1016 | + $checked = true; |
|
1017 | 1017 | |
1018 | - echo '<input name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="radio" value="' . $sanitize_key . '" ' . checked(true, $checked, false) . '/> '; |
|
1019 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option ) . '</label><br/>'; |
|
1020 | - endforeach; |
|
1018 | + echo '<input name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="radio" value="' . $sanitize_key . '" ' . checked(true, $checked, false) . '/> '; |
|
1019 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option ) . '</label><br/>'; |
|
1020 | + endforeach; |
|
1021 | 1021 | |
1022 | - echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
1022 | + echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
1023 | 1023 | } |
1024 | 1024 | |
1025 | 1025 | function wpinv_gateways_callback( $args ) { |
1026 | - global $wpinv_options; |
|
1026 | + global $wpinv_options; |
|
1027 | 1027 | |
1028 | 1028 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
1029 | 1029 | |
1030 | - foreach ( $args['options'] as $key => $option ) : |
|
1031 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
1030 | + foreach ( $args['options'] as $key => $option ) : |
|
1031 | + $sanitize_key = wpinv_sanitize_key( $key ); |
|
1032 | 1032 | |
1033 | 1033 | if ( isset( $wpinv_options['gateways'][ $key ] ) ) |
1034 | - $enabled = '1'; |
|
1035 | - else |
|
1036 | - $enabled = null; |
|
1034 | + $enabled = '1'; |
|
1035 | + else |
|
1036 | + $enabled = null; |
|
1037 | 1037 | |
1038 | - echo '<input name="wpinv_settings[' . esc_attr( $args['id'] ) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/> '; |
|
1039 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>'; |
|
1040 | - endforeach; |
|
1038 | + echo '<input name="wpinv_settings[' . esc_attr( $args['id'] ) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/> '; |
|
1039 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>'; |
|
1040 | + endforeach; |
|
1041 | 1041 | } |
1042 | 1042 | |
1043 | 1043 | function wpinv_gateway_select_callback($args) { |
1044 | - global $wpinv_options; |
|
1044 | + global $wpinv_options; |
|
1045 | 1045 | |
1046 | 1046 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
1047 | 1047 | |
1048 | - echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']">'; |
|
1048 | + echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']">'; |
|
1049 | 1049 | |
1050 | - foreach ( $args['options'] as $key => $option ) : |
|
1051 | - if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
|
1050 | + foreach ( $args['options'] as $key => $option ) : |
|
1051 | + if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
|
1052 | 1052 | $selected = selected( $key, $args['selected'], false ); |
1053 | 1053 | } else { |
1054 | 1054 | $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $key, $wpinv_options[$args['id']], false ) : ''; |
1055 | 1055 | } |
1056 | - echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>'; |
|
1057 | - endforeach; |
|
1056 | + echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>'; |
|
1057 | + endforeach; |
|
1058 | 1058 | |
1059 | - echo '</select>'; |
|
1060 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1059 | + echo '</select>'; |
|
1060 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1061 | 1061 | } |
1062 | 1062 | |
1063 | 1063 | function wpinv_text_callback( $args ) { |
1064 | - global $wpinv_options; |
|
1064 | + global $wpinv_options; |
|
1065 | 1065 | |
1066 | 1066 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
1067 | 1067 | |
1068 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1069 | - $value = $wpinv_options[ $args['id'] ]; |
|
1070 | - } else { |
|
1071 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1072 | - } |
|
1073 | - |
|
1074 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
1075 | - $args['readonly'] = true; |
|
1076 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1077 | - $name = ''; |
|
1078 | - } else { |
|
1079 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
1080 | - } |
|
1081 | - $class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : ''; |
|
1082 | - |
|
1083 | - $readonly = $args['readonly'] === true ? ' readonly="readonly"' : ''; |
|
1084 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
1085 | - $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"' . $readonly . '/>'; |
|
1086 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1087 | - |
|
1088 | - echo $html; |
|
1068 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1069 | + $value = $wpinv_options[ $args['id'] ]; |
|
1070 | + } else { |
|
1071 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1072 | + } |
|
1073 | + |
|
1074 | + if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
1075 | + $args['readonly'] = true; |
|
1076 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1077 | + $name = ''; |
|
1078 | + } else { |
|
1079 | + $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
1080 | + } |
|
1081 | + $class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : ''; |
|
1082 | + |
|
1083 | + $readonly = $args['readonly'] === true ? ' readonly="readonly"' : ''; |
|
1084 | + $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
1085 | + $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"' . $readonly . '/>'; |
|
1086 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1087 | + |
|
1088 | + echo $html; |
|
1089 | 1089 | } |
1090 | 1090 | |
1091 | 1091 | function wpinv_number_callback( $args ) { |
1092 | - global $wpinv_options; |
|
1092 | + global $wpinv_options; |
|
1093 | 1093 | |
1094 | 1094 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
1095 | 1095 | |
1096 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1097 | - $value = $wpinv_options[ $args['id'] ]; |
|
1098 | - } else { |
|
1099 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1100 | - } |
|
1101 | - |
|
1102 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
1103 | - $args['readonly'] = true; |
|
1104 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1105 | - $name = ''; |
|
1106 | - } else { |
|
1107 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
1108 | - } |
|
1109 | - |
|
1110 | - $max = isset( $args['max'] ) ? $args['max'] : 999999; |
|
1111 | - $min = isset( $args['min'] ) ? $args['min'] : 0; |
|
1112 | - $step = isset( $args['step'] ) ? $args['step'] : 1; |
|
1113 | - $class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : ''; |
|
1114 | - |
|
1115 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
1116 | - $html = '<input type="number" step="' . esc_attr( $step ) . '" max="' . esc_attr( $max ) . '" min="' . esc_attr( $min ) . '" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
1117 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1118 | - |
|
1119 | - echo $html; |
|
1096 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1097 | + $value = $wpinv_options[ $args['id'] ]; |
|
1098 | + } else { |
|
1099 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1100 | + } |
|
1101 | + |
|
1102 | + if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
1103 | + $args['readonly'] = true; |
|
1104 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1105 | + $name = ''; |
|
1106 | + } else { |
|
1107 | + $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
1108 | + } |
|
1109 | + |
|
1110 | + $max = isset( $args['max'] ) ? $args['max'] : 999999; |
|
1111 | + $min = isset( $args['min'] ) ? $args['min'] : 0; |
|
1112 | + $step = isset( $args['step'] ) ? $args['step'] : 1; |
|
1113 | + $class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : ''; |
|
1114 | + |
|
1115 | + $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
1116 | + $html = '<input type="number" step="' . esc_attr( $step ) . '" max="' . esc_attr( $max ) . '" min="' . esc_attr( $min ) . '" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
1117 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1118 | + |
|
1119 | + echo $html; |
|
1120 | 1120 | } |
1121 | 1121 | |
1122 | 1122 | function wpinv_textarea_callback( $args ) { |
1123 | - global $wpinv_options; |
|
1123 | + global $wpinv_options; |
|
1124 | 1124 | |
1125 | 1125 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
1126 | 1126 | |
1127 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1128 | - $value = $wpinv_options[ $args['id'] ]; |
|
1129 | - } else { |
|
1130 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1131 | - } |
|
1127 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1128 | + $value = $wpinv_options[ $args['id'] ]; |
|
1129 | + } else { |
|
1130 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1131 | + } |
|
1132 | 1132 | |
1133 | 1133 | $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
1134 | 1134 | $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text'; |
1135 | 1135 | |
1136 | - $html = '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
1137 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1136 | + $html = '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
1137 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1138 | 1138 | |
1139 | - echo $html; |
|
1139 | + echo $html; |
|
1140 | 1140 | } |
1141 | 1141 | |
1142 | 1142 | function wpinv_password_callback( $args ) { |
1143 | - global $wpinv_options; |
|
1143 | + global $wpinv_options; |
|
1144 | 1144 | |
1145 | 1145 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
1146 | 1146 | |
1147 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1148 | - $value = $wpinv_options[ $args['id'] ]; |
|
1149 | - } else { |
|
1150 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1151 | - } |
|
1147 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1148 | + $value = $wpinv_options[ $args['id'] ]; |
|
1149 | + } else { |
|
1150 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1151 | + } |
|
1152 | 1152 | |
1153 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
1154 | - $html = '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>'; |
|
1155 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1153 | + $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
1154 | + $html = '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>'; |
|
1155 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1156 | 1156 | |
1157 | - echo $html; |
|
1157 | + echo $html; |
|
1158 | 1158 | } |
1159 | 1159 | |
1160 | 1160 | function wpinv_missing_callback($args) { |
1161 | - printf( |
|
1162 | - __( 'The callback function used for the %s setting is missing.', 'invoicing' ), |
|
1163 | - '<strong>' . $args['id'] . '</strong>' |
|
1164 | - ); |
|
1161 | + printf( |
|
1162 | + __( 'The callback function used for the %s setting is missing.', 'invoicing' ), |
|
1163 | + '<strong>' . $args['id'] . '</strong>' |
|
1164 | + ); |
|
1165 | 1165 | } |
1166 | 1166 | |
1167 | 1167 | function wpinv_select_callback($args) { |
1168 | - global $wpinv_options; |
|
1168 | + global $wpinv_options; |
|
1169 | 1169 | |
1170 | 1170 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
1171 | 1171 | |
1172 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1173 | - $value = $wpinv_options[ $args['id'] ]; |
|
1174 | - } else { |
|
1175 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1176 | - } |
|
1172 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1173 | + $value = $wpinv_options[ $args['id'] ]; |
|
1174 | + } else { |
|
1175 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1176 | + } |
|
1177 | 1177 | |
1178 | 1178 | if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
1179 | 1179 | $value = $args['selected']; |
1180 | 1180 | } |
1181 | 1181 | |
1182 | - if ( isset( $args['placeholder'] ) ) { |
|
1183 | - $placeholder = $args['placeholder']; |
|
1184 | - } else { |
|
1185 | - $placeholder = ''; |
|
1186 | - } |
|
1182 | + if ( isset( $args['placeholder'] ) ) { |
|
1183 | + $placeholder = $args['placeholder']; |
|
1184 | + } else { |
|
1185 | + $placeholder = ''; |
|
1186 | + } |
|
1187 | 1187 | |
1188 | 1188 | if( !empty( $args['onchange'] ) ) { |
1189 | 1189 | $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"'; |
@@ -1191,142 +1191,142 @@ discard block |
||
1191 | 1191 | $onchange = ''; |
1192 | 1192 | } |
1193 | 1193 | |
1194 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" data-placeholder="' . esc_html( $placeholder ) . '"' . $onchange . ' />'; |
|
1194 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" data-placeholder="' . esc_html( $placeholder ) . '"' . $onchange . ' />'; |
|
1195 | 1195 | |
1196 | - foreach ( $args['options'] as $option => $name ) { |
|
1197 | - $selected = selected( $option, $value, false ); |
|
1198 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>'; |
|
1199 | - } |
|
1196 | + foreach ( $args['options'] as $option => $name ) { |
|
1197 | + $selected = selected( $option, $value, false ); |
|
1198 | + $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>'; |
|
1199 | + } |
|
1200 | 1200 | |
1201 | - $html .= '</select>'; |
|
1202 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1201 | + $html .= '</select>'; |
|
1202 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1203 | 1203 | |
1204 | - echo $html; |
|
1204 | + echo $html; |
|
1205 | 1205 | } |
1206 | 1206 | |
1207 | 1207 | function wpinv_color_select_callback( $args ) { |
1208 | - global $wpinv_options; |
|
1208 | + global $wpinv_options; |
|
1209 | 1209 | |
1210 | 1210 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
1211 | 1211 | |
1212 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1213 | - $value = $wpinv_options[ $args['id'] ]; |
|
1214 | - } else { |
|
1215 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1216 | - } |
|
1212 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1213 | + $value = $wpinv_options[ $args['id'] ]; |
|
1214 | + } else { |
|
1215 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1216 | + } |
|
1217 | 1217 | |
1218 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>'; |
|
1218 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>'; |
|
1219 | 1219 | |
1220 | - foreach ( $args['options'] as $option => $color ) { |
|
1221 | - $selected = selected( $option, $value, false ); |
|
1222 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>'; |
|
1223 | - } |
|
1220 | + foreach ( $args['options'] as $option => $color ) { |
|
1221 | + $selected = selected( $option, $value, false ); |
|
1222 | + $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>'; |
|
1223 | + } |
|
1224 | 1224 | |
1225 | - $html .= '</select>'; |
|
1226 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1225 | + $html .= '</select>'; |
|
1226 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1227 | 1227 | |
1228 | - echo $html; |
|
1228 | + echo $html; |
|
1229 | 1229 | } |
1230 | 1230 | |
1231 | 1231 | function wpinv_rich_editor_callback( $args ) { |
1232 | - global $wpinv_options, $wp_version; |
|
1232 | + global $wpinv_options, $wp_version; |
|
1233 | 1233 | |
1234 | 1234 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
1235 | 1235 | |
1236 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1237 | - $value = $wpinv_options[ $args['id'] ]; |
|
1236 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1237 | + $value = $wpinv_options[ $args['id'] ]; |
|
1238 | 1238 | |
1239 | - if( empty( $args['allow_blank'] ) && empty( $value ) ) { |
|
1240 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1241 | - } |
|
1242 | - } else { |
|
1243 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1244 | - } |
|
1239 | + if( empty( $args['allow_blank'] ) && empty( $value ) ) { |
|
1240 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1241 | + } |
|
1242 | + } else { |
|
1243 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1244 | + } |
|
1245 | 1245 | |
1246 | - $rows = isset( $args['size'] ) ? $args['size'] : 20; |
|
1246 | + $rows = isset( $args['size'] ) ? $args['size'] : 20; |
|
1247 | 1247 | |
1248 | - if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) { |
|
1249 | - ob_start(); |
|
1250 | - wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ) ) ); |
|
1251 | - $html = ob_get_clean(); |
|
1252 | - } else { |
|
1253 | - $html = '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
1254 | - } |
|
1248 | + if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) { |
|
1249 | + ob_start(); |
|
1250 | + wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ) ) ); |
|
1251 | + $html = ob_get_clean(); |
|
1252 | + } else { |
|
1253 | + $html = '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
1254 | + } |
|
1255 | 1255 | |
1256 | - $html .= '<br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1256 | + $html .= '<br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1257 | 1257 | |
1258 | - echo $html; |
|
1258 | + echo $html; |
|
1259 | 1259 | } |
1260 | 1260 | |
1261 | 1261 | function wpinv_upload_callback( $args ) { |
1262 | - global $wpinv_options; |
|
1262 | + global $wpinv_options; |
|
1263 | 1263 | |
1264 | 1264 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
1265 | 1265 | |
1266 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1267 | - $value = $wpinv_options[$args['id']]; |
|
1268 | - } else { |
|
1269 | - $value = isset($args['std']) ? $args['std'] : ''; |
|
1270 | - } |
|
1266 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1267 | + $value = $wpinv_options[$args['id']]; |
|
1268 | + } else { |
|
1269 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
1270 | + } |
|
1271 | 1271 | |
1272 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
1273 | - $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
1274 | - $html .= '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>'; |
|
1275 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1272 | + $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
1273 | + $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
1274 | + $html .= '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>'; |
|
1275 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1276 | 1276 | |
1277 | - echo $html; |
|
1277 | + echo $html; |
|
1278 | 1278 | } |
1279 | 1279 | |
1280 | 1280 | function wpinv_color_callback( $args ) { |
1281 | - global $wpinv_options; |
|
1281 | + global $wpinv_options; |
|
1282 | 1282 | |
1283 | 1283 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
1284 | 1284 | |
1285 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1286 | - $value = $wpinv_options[ $args['id'] ]; |
|
1287 | - } else { |
|
1288 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1289 | - } |
|
1285 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
1286 | + $value = $wpinv_options[ $args['id'] ]; |
|
1287 | + } else { |
|
1288 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
1289 | + } |
|
1290 | 1290 | |
1291 | - $default = isset( $args['std'] ) ? $args['std'] : ''; |
|
1291 | + $default = isset( $args['std'] ) ? $args['std'] : ''; |
|
1292 | 1292 | |
1293 | - $html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $default ) . '" />'; |
|
1294 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1293 | + $html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $default ) . '" />'; |
|
1294 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1295 | 1295 | |
1296 | - echo $html; |
|
1296 | + echo $html; |
|
1297 | 1297 | } |
1298 | 1298 | |
1299 | 1299 | function wpinv_country_states_callback($args) { |
1300 | - global $wpinv_options; |
|
1300 | + global $wpinv_options; |
|
1301 | 1301 | |
1302 | 1302 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
1303 | 1303 | |
1304 | - if ( isset( $args['placeholder'] ) ) { |
|
1305 | - $placeholder = $args['placeholder']; |
|
1306 | - } else { |
|
1307 | - $placeholder = ''; |
|
1308 | - } |
|
1304 | + if ( isset( $args['placeholder'] ) ) { |
|
1305 | + $placeholder = $args['placeholder']; |
|
1306 | + } else { |
|
1307 | + $placeholder = ''; |
|
1308 | + } |
|
1309 | 1309 | |
1310 | - $states = wpinv_get_country_states(); |
|
1310 | + $states = wpinv_get_country_states(); |
|
1311 | 1311 | |
1312 | - $class = empty( $states ) ? ' class="wpinv-no-states"' : ''; |
|
1313 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>'; |
|
1312 | + $class = empty( $states ) ? ' class="wpinv-no-states"' : ''; |
|
1313 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>'; |
|
1314 | 1314 | |
1315 | - foreach ( $states as $option => $name ) { |
|
1316 | - $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : ''; |
|
1317 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>'; |
|
1318 | - } |
|
1315 | + foreach ( $states as $option => $name ) { |
|
1316 | + $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : ''; |
|
1317 | + $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>'; |
|
1318 | + } |
|
1319 | 1319 | |
1320 | - $html .= '</select>'; |
|
1321 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1320 | + $html .= '</select>'; |
|
1321 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
1322 | 1322 | |
1323 | - echo $html; |
|
1323 | + echo $html; |
|
1324 | 1324 | } |
1325 | 1325 | |
1326 | 1326 | function wpinv_tax_rates_callback($args) { |
1327 | - global $wpinv_options; |
|
1328 | - $rates = wpinv_get_tax_rates(); |
|
1329 | - ob_start(); ?> |
|
1327 | + global $wpinv_options; |
|
1328 | + $rates = wpinv_get_tax_rates(); |
|
1329 | + ob_start(); ?> |
|
1330 | 1330 | </td><tr> |
1331 | 1331 | <td colspan="2" class="wpinv_tax_tdbox"> |
1332 | 1332 | <p><?php echo $args['desc']; ?></p> |
@@ -1350,39 +1350,39 @@ discard block |
||
1350 | 1350 | <tr> |
1351 | 1351 | <td class="wpinv_tax_country"> |
1352 | 1352 | <?php |
1353 | - echo wpinv_html_select( array( |
|
1354 | - 'options' => wpinv_get_country_list( true ), |
|
1355 | - 'name' => 'tax_rates[' . $sanitized_key . '][country]', |
|
1353 | + echo wpinv_html_select( array( |
|
1354 | + 'options' => wpinv_get_country_list( true ), |
|
1355 | + 'name' => 'tax_rates[' . $sanitized_key . '][country]', |
|
1356 | 1356 | 'id' => 'tax_rates[' . $sanitized_key . '][country]', |
1357 | - 'selected' => $rate['country'], |
|
1358 | - 'show_option_all' => false, |
|
1359 | - 'show_option_none' => false, |
|
1360 | - 'class' => 'wpinv-tax-country', |
|
1361 | - 'placeholder' => __( 'Choose a country', 'invoicing' ) |
|
1362 | - ) ); |
|
1363 | - ?> |
|
1357 | + 'selected' => $rate['country'], |
|
1358 | + 'show_option_all' => false, |
|
1359 | + 'show_option_none' => false, |
|
1360 | + 'class' => 'wpinv-tax-country', |
|
1361 | + 'placeholder' => __( 'Choose a country', 'invoicing' ) |
|
1362 | + ) ); |
|
1363 | + ?> |
|
1364 | 1364 | </td> |
1365 | 1365 | <td class="wpinv_tax_state"> |
1366 | 1366 | <?php |
1367 | - $states = wpinv_get_country_states( $rate['country'] ); |
|
1368 | - if( !empty( $states ) ) { |
|
1369 | - echo wpinv_html_select( array( |
|
1370 | - 'options' => array_merge( array( '' => '' ), $states ), |
|
1371 | - 'name' => 'tax_rates[' . $sanitized_key . '][state]', |
|
1367 | + $states = wpinv_get_country_states( $rate['country'] ); |
|
1368 | + if( !empty( $states ) ) { |
|
1369 | + echo wpinv_html_select( array( |
|
1370 | + 'options' => array_merge( array( '' => '' ), $states ), |
|
1371 | + 'name' => 'tax_rates[' . $sanitized_key . '][state]', |
|
1372 | 1372 | 'id' => 'tax_rates[' . $sanitized_key . '][state]', |
1373 | - 'selected' => $rate['state'], |
|
1374 | - 'show_option_all' => false, |
|
1375 | - 'show_option_none' => false, |
|
1376 | - 'placeholder' => __( 'Choose a state', 'invoicing' ) |
|
1377 | - ) ); |
|
1378 | - } else { |
|
1379 | - echo wpinv_html_text( array( |
|
1380 | - 'name' => 'tax_rates[' . $sanitized_key . '][state]', $rate['state'], |
|
1381 | - 'value' => ! empty( $rate['state'] ) ? $rate['state'] : '', |
|
1373 | + 'selected' => $rate['state'], |
|
1374 | + 'show_option_all' => false, |
|
1375 | + 'show_option_none' => false, |
|
1376 | + 'placeholder' => __( 'Choose a state', 'invoicing' ) |
|
1377 | + ) ); |
|
1378 | + } else { |
|
1379 | + echo wpinv_html_text( array( |
|
1380 | + 'name' => 'tax_rates[' . $sanitized_key . '][state]', $rate['state'], |
|
1381 | + 'value' => ! empty( $rate['state'] ) ? $rate['state'] : '', |
|
1382 | 1382 | 'id' => 'tax_rates[' . $sanitized_key . '][state]', |
1383 | - ) ); |
|
1384 | - } |
|
1385 | - ?> |
|
1383 | + ) ); |
|
1384 | + } |
|
1385 | + ?> |
|
1386 | 1386 | </td> |
1387 | 1387 | <td class="wpinv_tax_global"> |
1388 | 1388 | <input type="checkbox" name="tax_rates[<?php echo $sanitized_key; ?>][global]" id="tax_rates[<?php echo $sanitized_key; ?>][global]" value="1"<?php checked( true, ! empty( $rate['global'] ) ); ?>/> |
@@ -1397,19 +1397,19 @@ discard block |
||
1397 | 1397 | <tr> |
1398 | 1398 | <td class="wpinv_tax_country"> |
1399 | 1399 | <?php |
1400 | - echo wpinv_html_select( array( |
|
1401 | - 'options' => wpinv_get_country_list( true ), |
|
1402 | - 'name' => 'tax_rates[0][country]', |
|
1403 | - 'show_option_all' => false, |
|
1404 | - 'show_option_none' => false, |
|
1405 | - 'class' => 'wpinv-tax-country', |
|
1406 | - 'placeholder' => __( 'Choose a country', 'invoicing' ) |
|
1407 | - ) ); ?> |
|
1400 | + echo wpinv_html_select( array( |
|
1401 | + 'options' => wpinv_get_country_list( true ), |
|
1402 | + 'name' => 'tax_rates[0][country]', |
|
1403 | + 'show_option_all' => false, |
|
1404 | + 'show_option_none' => false, |
|
1405 | + 'class' => 'wpinv-tax-country', |
|
1406 | + 'placeholder' => __( 'Choose a country', 'invoicing' ) |
|
1407 | + ) ); ?> |
|
1408 | 1408 | </td> |
1409 | 1409 | <td class="wpinv_tax_state"> |
1410 | 1410 | <?php echo wpinv_html_text( array( |
1411 | - 'name' => 'tax_rates[0][state]' |
|
1412 | - ) ); ?> |
|
1411 | + 'name' => 'tax_rates[0][state]' |
|
1412 | + ) ); ?> |
|
1413 | 1413 | </td> |
1414 | 1414 | <td class="wpinv_tax_global"> |
1415 | 1415 | <input type="checkbox" name="tax_rates[0][global]" id="tax_rates[0][global]" value="1"/> |
@@ -1424,7 +1424,7 @@ discard block |
||
1424 | 1424 | <tfoot><tr><td colspan="5"></td><td class="wpinv_tax_action"><span class="button-secondary" id="wpinv_add_tax_rate"><?php _e( 'Add Tax Rate', 'invoicing' ); ?></span></td></tr></tfoot> |
1425 | 1425 | </table> |
1426 | 1426 | <?php |
1427 | - echo ob_get_clean(); |
|
1427 | + echo ob_get_clean(); |
|
1428 | 1428 | } |
1429 | 1429 | |
1430 | 1430 | function wpinv_tools_callback($args) { |
@@ -1452,15 +1452,15 @@ discard block |
||
1452 | 1452 | } |
1453 | 1453 | |
1454 | 1454 | function wpinv_descriptive_text_callback( $args ) { |
1455 | - echo wp_kses_post( $args['desc'] ); |
|
1455 | + echo wp_kses_post( $args['desc'] ); |
|
1456 | 1456 | } |
1457 | 1457 | |
1458 | 1458 | function wpinv_hook_callback( $args ) { |
1459 | - do_action( 'wpinv_' . $args['id'], $args ); |
|
1459 | + do_action( 'wpinv_' . $args['id'], $args ); |
|
1460 | 1460 | } |
1461 | 1461 | |
1462 | 1462 | function wpinv_set_settings_cap() { |
1463 | - return 'manage_options'; |
|
1463 | + return 'manage_options'; |
|
1464 | 1464 | } |
1465 | 1465 | add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' ); |
1466 | 1466 |