';
50 |
51 | foreach ( $images as $image ) { ?>
52 |
[0]; ?>)
58 | ';
61 |
62 | }
63 |
64 | }
65 |
66 | echo $this->element_after();
67 |
68 | }
69 |
70 | public static function enqueue( $args ) {
71 |
72 | // wp_enqueue_script( 'jquery-finderselect', $args['plugin_sof_url'] . 'assets/jquery.finderSelect.min.js', array( 'jquery' ), '0.7.0', true );
73 |
74 | // $script_file = 'loader-jquery-finderselect.min.js';
75 | // $script_name = 'exopite-sof-jquery-finderselect-loader';
76 |
77 | // wp_enqueue_script( $script_name, $args['plugin_sof_url'] . 'assets/' . $script_file, array( 'jquery-finderselect' ), filemtime( join( DIRECTORY_SEPARATOR, array(
78 | // $args['plugin_sof_path'] . 'assets',
79 | // $script_file
80 | // ) ) ), true );
81 |
82 | $resources = array(
83 | array(
84 | 'name' => 'jquery-finderselect',
85 | 'fn' => 'jquery.finderSelect.min.js',
86 | 'type' => 'script',
87 | 'dependency' => array( 'jquery' ),
88 | 'version' => '0.7.0',
89 | 'attr' => true,
90 | ),
91 | array(
92 | 'name' => 'exopite-sof-jquery-finderselect-loader',
93 | 'fn' => 'loader-jquery-finderselect.min.js',
94 | 'type' => 'script',
95 | 'dependency' => array( 'jquery-finderselect' ),
96 | 'version' => '',
97 | 'attr' => true,
98 | ),
99 | );
100 |
101 | parent::do_enqueue( $resources, $args );
102 |
103 | }
104 |
105 | }
106 |
107 | }
108 |
--------------------------------------------------------------------------------
/includes/admin/exopite-simple-options/fields/backup.php:
--------------------------------------------------------------------------------
1 | element_before();
22 |
23 | if ( $this->config['type'] == 'menu' ) {
24 |
25 | $nonce = wp_create_nonce( 'exopite_sof_backup' );
26 | $options = get_option( $this->unique );
27 | $export = esc_url( add_query_arg( array(
28 | 'action' => 'exopite-sof-export-options',
29 | 'export' => $this->unique,
30 | 'wpnonce' => $nonce
31 | ), admin_url( 'admin-ajax.php' ) ) );
32 |
33 | $encoded_options = '';
34 | if ( $options ) {
35 |
36 | $encoded_options = $this->encode_string( $options );
37 |
38 | }
39 |
40 | echo '
';
41 | echo '
( ' . esc_attr__( 'copy-paste your backup string here', 'exopite-sof' ) . ' )';
42 | echo '
' . esc_attr__( 'Import a Backup', 'exopite-sof' ) . '';
43 |
44 | echo '
';
45 | echo '
';
46 | echo '
' . esc_attr__( 'Download Backup', 'exopite-sof' ) . '';
47 |
48 | echo '
';
49 | echo '
' . esc_attr__( 'Please be sure for reset all of framework options.', 'exopite-sof' ) . '';
50 | echo '
' . esc_attr__( 'Reset All Options', 'exopite-sof' ) . '';
51 |
52 | echo '
';
53 |
54 | } else {
55 |
56 | echo 'This item only available in menu!
';
57 |
58 | }
59 |
60 | echo $this->element_after();
61 |
62 | }
63 |
64 | /**
65 | * Encode string for backup options
66 | */
67 | function encode_string( $option ) {
68 | return json_encode( $option );
69 | // return rtrim( strtr( call_user_func( 'base' . '64' . '_encode', addslashes( gzcompress( serialize( $option ), 9 ) ) ), '+/', '-_' ), '=' );
70 | }
71 |
72 | /**
73 | * Decode string for backup options
74 | */
75 | function decode_string( $option ) {
76 | return json_decode( $_POST['value'], true );
77 | // return unserialize( gzuncompress( stripslashes( call_user_func( 'base' . '64' . '_decode', rtrim( strtr( $option, '-_', '+/' ), '=' ) ) ) ) );
78 | }
79 |
80 | public static function enqueue( $args ) {
81 |
82 | /*
83 | * https://sweetalert.js.org/guides/
84 | */
85 | // wp_enqueue_script( 'sweetalert', '//unpkg.com/sweetalert/dist/sweetalert.min.js', false, '2.1.0', true );
86 | $resources = array(
87 | array(
88 | 'name' => 'sweetalert',
89 | 'fn' => 'sweetalert.min.js',
90 | 'type' => 'script',
91 | 'dependency' => false,
92 | 'version' => '2.1.0',
93 | 'attr' => true,
94 | ),
95 | );
96 |
97 | parent::do_enqueue( $resources, $args );
98 |
99 | }
100 |
101 | }
102 |
103 | }
104 |
--------------------------------------------------------------------------------
/includes/admin/exopite-simple-options/fields/button.php:
--------------------------------------------------------------------------------
1 | '',
19 | 'target' => '_self',
20 | 'value' => 'button',
21 | 'btn-class' => 'exopite-sof-btn',
22 | 'btn-id' => '',
23 | );
24 |
25 | $options = ( ! empty( $this->field['options'] ) ) ? $this->field['options'] : array();
26 |
27 | $this->field['options'] = wp_parse_args( $options, $defaults );
28 | }
29 |
30 | public function output() {
31 |
32 | $classes = ( isset( $this->field['class'] ) ) ? implode( ' ', explode( ' ', $this->field['class'] ) ) : '';
33 |
34 | echo $this->element_before();
35 | echo '
field['options']['href'] ) ) {
37 | echo 'href="' . $this->field['options']['href'] . '"';
38 | }
39 | if ( ! empty( $this->field['options']['btn-id'] ) ) {
40 | echo ' id="' . $this->field['options']['btn-id'] . '"';
41 | }
42 | echo ' target="' . $this->field['options']['target'] . '"';
43 | echo ' class="' . $this->field['options']['btn-class'] . ' ' . $classes . '"';
44 | echo $this->element_attributes() . '/>' . $this->field['options']['value'] . '';
45 | echo $this->element_after();
46 |
47 | }
48 |
49 | }
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/includes/admin/exopite-simple-options/fields/button_bar.php:
--------------------------------------------------------------------------------
1 | element_before();
20 |
21 | if ( isset( $this->field['options'] ) ) {
22 |
23 | $options = $this->field['options'];
24 | $options = ( is_array( $options ) ) ? $options : array_filter( $this->element_data( $options ) );
25 |
26 | if ( ! empty( $options ) ) {
27 |
28 | echo '
';
37 | }
38 |
39 | }
40 |
41 | echo $this->element_after();
42 |
43 | }
44 |
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/includes/admin/exopite-simple-options/fields/card.php:
--------------------------------------------------------------------------------
1 | field['class'] ) ) ? implode( ' ', explode( ' ', $this->field['class'] ) ) : '';
20 |
21 | echo $this->element_before();
22 |
23 | echo '
';
24 |
25 | if ( ! empty( $this->field['header'] ) ) {
26 | echo '';
29 | }
30 |
31 | echo '
';
32 |
33 | if ( ! empty( $this->field['title'] ) ) {
34 | echo '
' . $this->field['title'] . '
';
35 | }
36 |
37 | echo '
' . $this->field['content'] . '
';
38 |
39 | echo '
';
40 |
41 | if ( ! empty( $this->field['footer'] ) ) {
42 | echo '';
45 | }
46 |
47 | echo '
';
48 |
49 | echo $this->element_after();
50 |
51 | }
52 |
53 | }
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/includes/admin/exopite-simple-options/fields/checkbox.php:
--------------------------------------------------------------------------------
1 | element_before();
22 | $label = ( isset( $this->field['label'] ) ) ? $this->field['label'] : '';
23 | $style = ( isset( $this->field['style'] ) ) ? $this->field['style'] : '';
24 |
25 | switch ( $style ) {
26 | case 'fancy':
27 | echo '
';
32 | break;
33 |
34 | default:
35 | echo '
';
36 | break;
37 | }
38 |
39 |
40 | echo $this->element_after();
41 |
42 | }
43 |
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/includes/admin/exopite-simple-options/fields/color.php:
--------------------------------------------------------------------------------
1 | field['class'] ) ) ? implode( ' ', explode( ' ', $this->field['class'] ) ) : '';
21 | $controls = array( 'hue', 'brightness', 'saturation', 'wheel' );
22 | $control = ( isset( $this->field['control'] ) ) ? $this->field['control'] : 'saturation';
23 | $formats = array( 'rgb', 'hex' );
24 | $format = ( isset( $this->field['format'] ) ) ? $this->field['format'] : 'rgb';
25 |
26 | echo $this->element_before();
27 | echo '
field['picker'] ) || $this->field['picker'] != 'html5' ) {
35 | echo 'class="minicolor ' . $classes . '" ';
36 | }
37 | if ( isset( $this->field['rgba'] ) && $this->field['rgba'] ) {
38 | echo 'data-opacity="1" ';
39 | }
40 | if ( in_array( $control, $controls ) ) {
41 | echo 'data-control="' . $control . '" '; // hue, brightness, saturation, wheel
42 | }
43 | if ( in_array( $format, $formats ) ) {
44 | echo 'data-format="' . $format . '" '; // hue, brightness, saturation, wheel
45 | }
46 | echo 'name="' . $this->element_name() . '" value="' . $this->element_value() . '"';
47 | if ( isset( $this->field['picker'] ) && $this->field['picker'] == 'html5' ) {
48 | echo $this->element_class();
49 | }
50 | echo $this->element_attributes() . '/>';
51 |
52 | }
53 |
54 | public static function enqueue( $args ) {
55 |
56 | $resources = array(
57 | array(
58 | 'name' => 'minicolors_css',
59 | 'fn' => 'jquery.minicolors.css',
60 | 'type' => 'style',
61 | 'dependency' => array(),
62 | 'version' => '20181201',
63 | 'attr' => 'all',
64 | ),
65 | array(
66 | 'name' => 'minicolors_js',
67 | 'fn' => 'jquery.minicolors.js',
68 | 'type' => 'script',
69 | 'dependency' => array( 'jquery' ),
70 | 'version' => '20181201',
71 | 'attr' => true,
72 | ),
73 | array(
74 | 'name' => 'minicolors-loader',
75 | 'fn' => 'loader-minicolors.js',
76 | 'type' => 'script',
77 | 'dependency' => array( 'minicolors_js' ),
78 | 'version' => '20190407',
79 | 'attr' => true,
80 | ),
81 | );
82 |
83 | parent::do_enqueue( $resources, $args );
84 |
85 | }
86 |
87 | }
88 |
89 | }
90 |
--------------------------------------------------------------------------------
/includes/admin/exopite-simple-options/fields/color_wp.php:
--------------------------------------------------------------------------------
1 | field['class'] ) ) ? implode( ' ', explode( ' ', $this->field['class'] ) ) : '';
21 |
22 | /*
23 | * Color Picker
24 | *
25 | * @link https://paulund.co.uk/adding-a-new-color-picker-with-wordpress-3-5
26 | */
27 |
28 | echo $this->element_before();
29 | echo '
field['rgba'] ) && $this->field['rgba'] ) {
31 | echo 'data-alpha="true" ';
32 | }
33 | echo 'name="' . $this->element_name() . '" value="' . $this->element_value() . '"';
34 | echo $this->element_attributes() . '/>';
35 |
36 | }
37 |
38 | public static function enqueue( $args ) {
39 |
40 | // Add the color picker css file from WordPress
41 | wp_enqueue_style( 'wp-color-picker' );
42 |
43 | $resources = array(
44 | array(
45 | 'name' => 'wp-color-picker-alpha',
46 | 'fn' => 'wp-color-picker-alpha.min.js',
47 | 'type' => 'script',
48 | 'dependency' => array( 'wp-color-picker' ),
49 | 'version' => '2.1.3',
50 | 'attr' => true,
51 | ),
52 | array(
53 | 'name' => 'exopite-sof-wp-color-picker-loader',
54 | 'fn' => 'loader-color-picker.min.js',
55 | 'type' => 'script',
56 | 'dependency' => array( 'wp-color-picker-alpha' ),
57 | 'version' => '20190407',
58 | 'attr' => true,
59 | ),
60 | );
61 |
62 | parent::do_enqueue( $resources, $args );
63 |
64 | }
65 |
66 | }
67 |
68 | }
69 |
--------------------------------------------------------------------------------
/includes/admin/exopite-simple-options/fields/content.php:
--------------------------------------------------------------------------------
1 | field['content'] ) ) ? $this->field['content'] : '';
20 |
21 | if ( isset( $this->field['callback'] ) ) {
22 |
23 | $callback = $this->field['callback'];
24 | if ( is_callable( $callback['function'] ) ) {
25 |
26 | $args = ( isset( $callback['args'] ) ) ? $callback['args'] : '';
27 | $content = call_user_func( $callback['function'], $args );
28 |
29 | }
30 | }
31 |
32 | echo $this->element_before();
33 | echo '
element_class() . $this->element_attributes() . '>' . $content . '
';
34 | echo $this->element_after();
35 |
36 | }
37 |
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/includes/admin/exopite-simple-options/fields/date.php:
--------------------------------------------------------------------------------
1 | field['format'] ) ) ? $this->field['format'] : 'mm/dd/yy';
20 | $classes = ( isset( $this->field['class'] ) ) ? implode( ' ', explode( ' ', $this->field['class'] ) ) : '';
21 |
22 | echo $this->element_before();
23 |
24 | echo $this->element_prepend();
25 |
26 | if ( isset( $this->field['picker'] ) && $this->field['picker'] == 'html5' ) {
27 | echo '
element_name() . '" ';
33 | if ( isset( $this->field['picker'] ) && $this->field['picker'] == 'html5' ) {
34 | echo 'value="' . $this->element_value() . '"' . $this->element_class() . $this->element_attributes() . ' ';
35 | } else {
36 | echo 'value="' . $this->element_value() . '"' . $this->element_attributes() . ' ';
37 | echo 'data-format="' . $date_format . '"';
38 | }
39 | echo '>';
40 |
41 | echo $this->element_append();
42 |
43 | echo $this->element_after();
44 |
45 | }
46 |
47 | public static function enqueue( $args ) {
48 |
49 | $resources = array(
50 | array(
51 | 'name' => 'exopite-sof-datepicker-loader',
52 | 'fn' => 'loader-datepicker.min.js',
53 | 'type' => 'script',
54 | 'dependency' => array( 'jquery' ),
55 | 'version' => '',
56 | 'attr' => true,
57 | ),
58 | );
59 |
60 | parent::do_enqueue( $resources, $args );
61 |
62 | }
63 |
64 | }
65 |
66 | }
67 |
--------------------------------------------------------------------------------
/includes/admin/exopite-simple-options/fields/editor.php:
--------------------------------------------------------------------------------
1 | field['class'] ) ) ? explode( ' ', $this->field['class'] ) : array();//$this->element_class()
20 | $editor = ( isset( $this->field['editor'] ) ) ? $this->field['editor'] : 'tinymce';
21 |
22 | echo $this->element_before();
23 |
24 | if ( $editor == 'tinymce' && isset( $this->field['sub'] ) && $this->field['sub'] ) {
25 |
26 | $classes[] = 'tinymce-js';
27 | $classes = implode( ' ', $classes );
28 |
29 | echo '
';
30 |
31 | } elseif ( $editor == 'trumbowyg' ) {
32 |
33 | $classes[] = 'trumbowyg-js';
34 | $classes = implode( ' ', $classes );
35 |
36 | echo '
';
37 |
38 | } else {
39 |
40 | $args = array(
41 | 'textarea_rows' => 15,
42 | 'editor_class' => implode( ' ', $classes ),
43 | 'textarea_name' => $this->element_name(),
44 | 'teeny' => false,
45 | // output the minimal editor config used in Press This
46 | 'dfw' => false,
47 | // replace the default fullscreen with DFW (supported on the front-end in WordPress 3.4)
48 | 'tinymce' => true,
49 | // load TinyMCE, can be used to pass settings directly to TinyMCE using an array()
50 | 'quicktags' => true
51 | // load Quicktags, can be used to pass settings directly to Quicktags using an array()
52 | );
53 |
54 | wp_editor( $this->element_value(), $this->field['id'], $args );
55 |
56 | }
57 |
58 | echo $this->element_after();
59 |
60 | }
61 |
62 | public static function enqueue( $args ) {
63 |
64 | if ( isset( $args['field'] ) && isset( $args['field']['editor'] ) && is_array( $args['field']['editor'] ) ) {
65 |
66 | foreach ( $args['field']['editor'] as $editor ) {
67 |
68 | switch ( $editor ) {
69 |
70 | case 'trumbowyg':
71 |
72 | $resources = array(
73 | array(
74 | 'name' => 'trumbowyg',
75 | 'fn' => 'editors/trumbowyg/trumbowyg.min.css',
76 | 'type' => 'style',
77 | 'dependency' => array(),
78 | 'version' => '2.10.0',
79 | 'attr' => 'all',
80 | ),
81 | array(
82 | 'name' => 'trumbowyg-colors',
83 | 'fn' => 'editors/trumbowyg/trumbowyg.colors.min.css',
84 | 'type' => 'style',
85 | 'dependency' => array(),
86 | 'version' => '2.10.0',
87 | 'attr' => 'all',
88 | ),
89 | array(
90 | 'name' => 'trumbowyg-user',
91 | 'fn' => 'editors/trumbowyg/trumbowyg.user.min.css',
92 | 'type' => 'style',
93 | 'dependency' => array(),
94 | 'version' => '2.10.0',
95 | 'attr' => 'all',
96 | ),
97 | array(
98 | 'name' => 'trumbowyg',
99 | 'fn' => 'editors/trumbowyg/trumbowyg.min.js',
100 | 'type' => 'script',
101 | 'dependency' => array( 'jquery' ),
102 | 'version' => '1.8.2',
103 | 'attr' => true,
104 | ),
105 | array(
106 | 'name' => 'trumbowyg-base64',
107 | 'fn' => 'editors/trumbowyg/trumbowyg.base64.min.js',
108 | 'type' => 'script',
109 | 'dependency' => array( 'trumbowyg' ),
110 | 'version' => '1.8.2',
111 | 'attr' => true,
112 | ),
113 | array(
114 | 'name' => 'trumbowyg-colors',
115 | 'fn' => 'editors/trumbowyg/trumbowyg.colors.min.js',
116 | 'type' => 'script',
117 | 'dependency' => array( 'trumbowyg' ),
118 | 'version' => '1.8.2',
119 | 'attr' => true,
120 | ),
121 | array(
122 | 'name' => 'trumbowyg-fontfamily',
123 | 'fn' => 'editors/trumbowyg/trumbowyg.fontfamily.min.js',
124 | 'type' => 'script',
125 | 'dependency' => array( 'trumbowyg' ),
126 | 'version' => '1.8.2',
127 | 'attr' => true,
128 | ),
129 | array(
130 | 'name' => 'trumbowyg-fontsize',
131 | 'fn' => 'editors/trumbowyg/trumbowyg.fontsize.min.js',
132 | 'type' => 'script',
133 | 'dependency' => array( 'trumbowyg' ),
134 | 'version' => '1.8.2',
135 | 'attr' => true,
136 | ),
137 | array(
138 | 'name' => 'exopite-sof-trumbowyg-loader',
139 | 'fn' => 'loader-jquery-trumbowyg.min.js',
140 | 'type' => 'script',
141 | 'dependency' => array( 'trumbowyg' ),
142 | 'version' => '',
143 | 'attr' => true,
144 | ),
145 |
146 | );
147 |
148 | parent::do_enqueue( $resources, $args );
149 |
150 | break;
151 |
152 | }
153 |
154 | }
155 |
156 | }
157 |
158 |
159 | }
160 |
161 | }
162 |
163 | }
164 |
--------------------------------------------------------------------------------
/includes/admin/exopite-simple-options/fields/fieldset.php:
--------------------------------------------------------------------------------
1 | element_before();
24 |
25 | $unallows = array();
26 | $unique_id = ( ! empty( $this->unique ) ) ? $this->unique : $this->field['id'];
27 |
28 | $self = new Exopite_Simple_Options_Framework( array(
29 | 'id' => $this->element_name(),
30 | 'multilang' => $this->config['multilang'],
31 | 'is_options_simple' => $this->config['is_options_simple'],
32 | ), null );
33 |
34 | $i = 0;
35 |
36 | $fields = $this->field['fields'];
37 |
38 | echo '
';
39 | echo '
';
40 |
41 | /**
42 | * 1 -> col-12 col-lg-12 (12/index)
43 | * 2 -> col-12 col-lg-6
44 | * 3 -> col-12 col-lg-4
45 | * 4 -> col-12 col-lg-3
46 | * 6 -> col-12 col-lg-2
47 | */
48 |
49 | $col_classes = array( 'col', 'col-xs-12' );
50 | $allowed_cols = array( 1, 2, 3, 4, 6 );
51 | $col_number = ( isset( $this->field['options']['cols'] ) ) ? intval( $this->field['options']['cols'] ) : 1;
52 | if ( ! in_array( $col_number, $allowed_cols ) ) {
53 | $col_number = 1;
54 | } else {
55 | $col_classes[] = 'col-lg-' . ( 12 / $col_number );
56 | $col_classes[] = 'exopite-sof-col-lg';
57 | }
58 |
59 | foreach ( $fields as $field ) {
60 |
61 | echo '
';
62 |
63 | if ( in_array( $field['type'], $unallows ) ) {
64 | $field['_notice'] = true;
65 | continue;
66 | }
67 |
68 | if ( is_serialized( $this->value ) ) {
69 | $this->value = unserialize( $this->value );
70 | }
71 |
72 | $field_value = '';
73 | if ( isset( $field['id'] ) && isset( $this->value[ $field['id'] ] ) ) {
74 | $field_value = $this->value[ $field['id'] ];
75 | } elseif ( isset( $field['default'] ) ) {
76 | $field_value = $field['default'];
77 | }
78 |
79 | $class = 'Exopite_Simple_Options_Framework_Field_' . $field['type'];
80 |
81 | echo $self->add_field( $field, $field_value );
82 |
83 | echo '
'; // col
84 |
85 | }
86 |
87 | echo '
'; // row
88 | echo '
'; // container
89 |
90 | echo $this->element_after();
91 |
92 | }
93 |
94 | }
95 |
96 | }
97 |
--------------------------------------------------------------------------------
/includes/admin/exopite-simple-options/fields/gallery.php:
--------------------------------------------------------------------------------
1 | element_before();
21 |
22 | echo $this->element_prepend();
23 |
24 | $defaults = array(
25 | 'add_button' => esc_attr__( 'Add to gallery', 'exopite-sof' ),
26 | 'media_frame_title' => esc_attr__( 'Select images for gallery', 'exopite-sof' ),
27 | 'media_frame_button' => esc_attr__( 'Add', 'exopite-sof' ),
28 | 'media_type' => 'image',
29 | );
30 |
31 | $options = ( isset( $field['options'] ) && is_array( $field['options'] ) ) ? $field['options'] : array();
32 | $options = wp_parse_args( $options, $defaults );
33 |
34 | $value = $this->element_value();
35 |
36 | echo '
';
37 | echo '
element_class() . $this->element_attributes() . '/>';
38 | echo '
';
39 |
40 | if ( $value ) :
41 |
42 | $meta_array = explode( ',', $value );
43 | foreach ( $meta_array as $meta_gall_item ) :
44 |
45 | echo '
 . ')
';
46 |
47 | endforeach;
48 |
49 | endif;
50 |
51 | echo '
';
52 | echo '
';
53 | echo '
';
54 |
55 | echo $this->element_append();
56 |
57 | echo $this->element_after();
58 |
59 | }
60 |
61 | }
62 |
63 | }
64 |
--------------------------------------------------------------------------------
/includes/admin/exopite-simple-options/fields/hidden.php:
--------------------------------------------------------------------------------
1 | element_before();
20 | echo '
element_class() . $this->element_attributes() . '/>';
21 | echo $this->element_after();
22 |
23 | }
24 |
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/includes/admin/exopite-simple-options/fields/image.php:
--------------------------------------------------------------------------------
1 | 'attachment',
38 | 'post_status' => 'inherit',
39 | 'fields' => 'ids',
40 | 'meta_query' => array(
41 | array(
42 | 'value' => $file,
43 | 'compare' => 'LIKE',
44 | 'key' => '_wp_attachment_metadata',
45 | ),
46 | )
47 | );
48 | $query = new WP_Query( $query_args );
49 | if ( $query->have_posts() ) {
50 | foreach ( $query->posts as $post_id ) {
51 | $meta = wp_get_attachment_metadata( $post_id );
52 | $original_file = basename( $meta['file'] );
53 | $cropped_image_files = wp_list_pluck( $meta['sizes'], 'file' );
54 | if ( $original_file === $file || in_array( $file, $cropped_image_files ) ) {
55 | $attachment_id = $post_id;
56 | break;
57 | }
58 | }
59 | }
60 | }
61 |
62 | return $attachment_id;
63 | }
64 |
65 | public function output() {
66 |
67 | /**
68 | * Open WordPress Media Uploader with PHP and JavaScript
69 | *
70 | * @link https://rudrastyh.com/wordpress/customizable-media-uploader.html
71 | */
72 |
73 | echo $this->element_before();
74 |
75 | $preview = '';
76 | $value = $this->element_value();
77 | $add = ( ! empty( $this->field['add_title'] ) ) ? $this->field['add_title'] : esc_attr__( '选择图片', 'exopite-sof' );
78 | $hidden = ( empty( $value ) ) ? ' hidden' : '';
79 | $classes = ( isset( $this->field['class'] ) ) ? implode( ' ', explode( ' ', $this->field['class'] ) ) : '';
80 |
81 | if ( ! empty( $value ) ) {
82 | $attachment = wp_get_attachment_image_src( $this->get_attachment_id( $value ), 'thumbnail' );
83 | $preview = $attachment[0];
84 | }
85 |
86 | echo '
';
94 | echo $this->element_after();
95 |
96 | }
97 |
98 | public static function enqueue( $args ) {
99 |
100 | wp_enqueue_media();
101 |
102 | }
103 |
104 | }
105 |
106 | }
107 |
--------------------------------------------------------------------------------
/includes/admin/exopite-simple-options/fields/image_select.php:
--------------------------------------------------------------------------------
1 | field['radio'] ) ) ? 'radio' : 'checkbox';
20 | $input_attr = ( $input_type == 'checkbox' ) ? '[]' : '';
21 | $layout = ( isset( $this->field['layout'] ) && $this->field['layout'] == 'vertical' ) ? 'exopite-sof-field-image-selector-vertical' : 'exopite-sof-field-image-selector-horizontal';
22 |
23 | echo $this->element_before();
24 | echo '
';
25 | // echo ( empty( $input_attr ) ) ? '
';
37 | // echo ( empty( $input_attr ) ) ? '
' : '';
38 | echo $this->element_after();
39 |
40 | }
41 |
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/includes/admin/exopite-simple-options/fields/index.php:
--------------------------------------------------------------------------------
1 | config['type'] != 'metabox') {
20 |
21 | echo 'This item only available in metabox!
';
22 |
23 | } else {
24 |
25 | if ( ! empty( $this->field['meta-key'] ) ) {
26 |
27 | $value = get_post_meta( get_the_ID(), $this->field['meta-key'], true );
28 |
29 | echo $this->element_before();
30 | echo '
';
31 | echo $this->element_after();
32 | }
33 |
34 | }
35 |
36 |
37 | }
38 |
39 |
40 | }
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/includes/admin/exopite-simple-options/fields/notice.php:
--------------------------------------------------------------------------------
1 | field['class'] ) ) ? implode( ' ', explode( ' ', $this->field['class'] ) ) : '';
20 |
21 | $content = ( isset( $this->field['content'] ) ) ? $this->field['content'] : '';
22 |
23 | if ( isset( $this->field['callback'] ) ) {
24 |
25 | $callback = $this->field['callback'];
26 | if ( is_callable( $callback['function'] ) ) {
27 |
28 | $args = ( isset( $callback['args'] ) ) ? $callback['args'] : '';
29 | $content = call_user_func( $callback['function'], $args );
30 |
31 | }
32 | }
33 |
34 | echo $this->element_before();
35 | echo '
' . $content . '
';
36 | echo $this->element_after();
37 |
38 | }
39 |
40 | }
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/includes/admin/exopite-simple-options/fields/number.php:
--------------------------------------------------------------------------------
1 | element_before();
20 |
21 | $unit = ( isset( $this->field['unit'] ) ) ? '
' . $this->field['unit'] . '' : '';
22 |
23 | $attr = array();
24 | if ( isset( $this->field['min'] ) ) {
25 | $attr[] = 'min="' . $this->field['min'] . '"';
26 | }
27 | if ( isset( $this->field['max'] ) ) {
28 | $attr[] = 'max="' . $this->field['max'] . '"';
29 | }
30 | if ( isset( $this->field['step'] ) ) {
31 | $attr[] = 'step="' . $this->field['step'] . '"';
32 | }
33 | $attrs = ( ! empty( $attr ) ) ? ' ' . trim( implode( ' ', $attr ) ) : '';
34 |
35 | echo $this->element_prepend();
36 |
37 | echo '
element_class() . $this->element_attributes() . $attrs . '/>';
38 |
39 | echo $this->element_append();
40 |
41 | echo $unit;
42 |
43 | echo $this->element_after();
44 |
45 | }
46 |
47 | }
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/includes/admin/exopite-simple-options/fields/password.php:
--------------------------------------------------------------------------------
1 | element_before();
20 |
21 | echo $this->element_prepend();
22 |
23 | echo '
element_class() . $this->element_attributes() . '/>';
24 |
25 | echo $this->element_append();
26 |
27 | echo $this->element_after();
28 |
29 | }
30 |
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/includes/admin/exopite-simple-options/fields/radio.php:
--------------------------------------------------------------------------------
1 | field['class'] ) ) ? implode( ' ', explode( ' ', $this->field['class'] ) ) : '';
20 |
21 | echo $this->element_before();
22 |
23 | if ( isset( $this->field['options'] ) ) {
24 |
25 | $options = $this->field['options'];
26 | $options = ( is_array( $options ) ) ? $options : array_filter( $this->element_data( $options ) );
27 | $style = ( isset( $this->field['style'] ) ) ? $this->field['style'] : '';
28 |
29 | if ( ! empty( $options ) ) {
30 |
31 | echo '
';
52 | }
53 |
54 | } else {
55 | $label = ( isset( $this->field['label'] ) ) ? $this->field['label'] : '';
56 |
57 | switch ( $this->field['style'] ) {
58 | case 'fancy':
59 | echo '
';
64 | break;
65 |
66 | default:
67 | echo '
';
68 | break;
69 | }
70 |
71 | }
72 |
73 | echo $this->element_after();
74 |
75 | }
76 |
77 | }
78 |
79 | }
80 |
--------------------------------------------------------------------------------
/includes/admin/exopite-simple-options/fields/range.php:
--------------------------------------------------------------------------------
1 | field['min'] ) ) {
26 | $attr[] = 'min="' . $this->field['min'] . '"';
27 | }
28 | if ( ! empty( $this->field['max'] ) ) {
29 | $attr[] = 'max="' . $this->field['max'] . '"';
30 | }
31 | if ( ! empty( $this->field['step'] ) ) {
32 | $attr[] = 'step="' . $this->field['step'] . '"';
33 | }
34 | $attrs = ( ! empty( $attr ) ) ? ' ' . trim( implode( ' ', $attr ) ) : '';
35 | $unit = ( isset( $this->field['unit'] ) ) ? '
' . $this->field['unit'] . '' : '';
36 | $classes = ( isset( $this->field['class'] ) ) ? implode( ' ', explode( ' ', $this->field['class'] ) ) : '';
37 |
38 | echo $this->element_before();
39 |
40 | echo '
element_attributes() . '>' . $unit;
41 | echo '
';
42 |
43 | echo $this->element_after();
44 |
45 | }
46 |
47 | }
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/includes/admin/exopite-simple-options/fields/switcher.php:
--------------------------------------------------------------------------------
1 | element_before();
20 | $label = ( isset( $this->field['label'] ) ) ? '
' . $this->field['label'] . '
' : '';
21 |
22 | $classes = ( isset( $this->field['class'] ) ) ? implode( ' ', explode( ' ', $this->field['class'] ) ) : '';
23 |
24 | echo '
' . $label;
28 | echo $this->element_after();
29 |
30 | }
31 |
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/includes/admin/exopite-simple-options/fields/tab.php:
--------------------------------------------------------------------------------
1 | element_before();
20 |
21 | $unallows = array();
22 | $tabs = array_values( $this->field['tabs'] );
23 | $unique_id = ( ! empty( $this->unique ) ) ? $this->unique : $this->field['id'];
24 |
25 | $self = new Exopite_Simple_Options_Framework( array(
26 | 'id' => $this->element_name(),
27 | 'multilang' => $this->config['multilang'],
28 | 'is_options_simple' => $this->config['is_options_simple'],
29 | ), null );
30 |
31 | echo '
';
32 |
33 | $i = 0;
34 |
35 | $equal_width = ( isset( $this->field['options']['equal_width'] ) && $this->field['options']['equal_width'] ) ? ' equal-width' : '';
36 |
37 | /**
38 | * Tab navigation
39 | */
40 | echo '';
52 |
53 | /**
54 | * Tab content
55 | */
56 | foreach ( $tabs as $key => $tab ) {
57 |
58 | reset( $tabs );
59 | $tab_active = ( $key === key( $tabs ) ) ? ' active' : '';
60 |
61 | echo '
';
62 | echo '';
63 | echo '
';
64 | echo '
';
65 |
66 | foreach ( $tab['fields'] as $field ) {
67 |
68 | if ( in_array( $field['type'], $unallows ) ) {
69 | $field['_notice'] = true;
70 | continue;
71 | }
72 |
73 | if ( is_serialized( $this->value ) ) {
74 | $this->value = unserialize( $this->value );
75 | }
76 |
77 | $field_value = '';
78 | if ( isset( $this->value[ $field['id'] ] ) ) {
79 | $field_value = $this->value[ $field['id'] ];
80 | } elseif ( isset( $field['default'] ) ) {
81 | $field_value = $field['default'];
82 | }
83 |
84 | $class = 'Exopite_Simple_Options_Framework_Field_' . $field['type'];
85 |
86 | echo $self->add_field( $field, $field_value );
87 |
88 | }
89 |
90 | echo '
';
91 | echo '
';
92 | echo '
';
93 |
94 | }
95 |
96 | echo '
';
97 |
98 | echo $this->element_after();
99 |
100 | }
101 |
102 | }
103 |
104 | }
105 |
--------------------------------------------------------------------------------
/includes/admin/exopite-simple-options/fields/tap_list.php:
--------------------------------------------------------------------------------
1 | field['radio'] ) ) ? 'radio' : 'checkbox';
20 | $input_attr = ( $input_type == 'checkbox' ) ? '[]' : '';
21 |
22 | echo $this->element_before();
23 |
24 | if ( isset( $this->field['options'] ) ) {
25 |
26 | echo '
';
27 |
28 | $options = $this->field['options'];
29 | foreach ( $options as $key => $value ) {
30 |
31 | echo '- ';
32 | echo '';
56 | echo '';
59 | echo '
';
60 |
61 | }
62 |
63 | echo '
';
64 | }
65 |
66 | echo $this->element_after();
67 |
68 | }
69 |
70 | }
71 |
72 | }
73 |
--------------------------------------------------------------------------------
/includes/admin/exopite-simple-options/fields/text.php:
--------------------------------------------------------------------------------
1 | element_before();
21 |
22 | echo $this->element_prepend();
23 |
24 | echo '
element_class() . $this->element_attributes() . '/>';
25 |
26 | echo $this->element_append();
27 |
28 | echo $this->element_after();
29 |
30 | }
31 |
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/includes/admin/exopite-simple-options/fields/textarea.php:
--------------------------------------------------------------------------------
1 | element_before();
20 | echo '
';
21 | echo $this->element_after();
22 |
23 | }
24 |
25 |
26 | }
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/includes/admin/exopite-simple-options/fields/video.php:
--------------------------------------------------------------------------------
1 | true,
19 | 'oembed' => false,
20 | 'url' => '',
21 | 'loop' => '',
22 | 'autoplay' => '',
23 | 'muted' => 'muted',
24 | 'controls' => 'controls'
25 | );
26 |
27 | $options = ( ! empty( $this->field['options'] ) ) ? $this->field['options'] : array();
28 | $this->field['options'] = wp_parse_args( $options, $defaults );
29 |
30 | }
31 |
32 | public function output() {
33 |
34 | echo $this->element_before();
35 |
36 | echo '
';
81 |
82 | echo $this->element_after();
83 |
84 | }
85 |
86 | }
87 |
88 | }
89 |
--------------------------------------------------------------------------------
/includes/admin/exopite-simple-options/index.php:
--------------------------------------------------------------------------------
1 | get_default_language();
110 | $multilang['current'] = $sitepress->get_current_language();
111 | $active_languages = $sitepress->get_active_languages();
112 |
113 | if ( is_array( $active_languages ) ) {
114 | $multilang['languages'] = array_keys( $active_languages );
115 | }
116 |
117 | break; // case( 'wpml' )
118 |
119 | case( 'polylang' ):
120 |
121 | // These checks of function_exists() and method_exists() added as deactivating polylang was giving fatal error
122 |
123 | global $polylang;
124 |
125 | if ( function_exists( 'pll_current_language' ) ) {
126 | $current = pll_current_language();
127 | }
128 |
129 | if ( function_exists( 'pll_default_language' ) ) {
130 | $default = pll_default_language();
131 | }
132 |
133 | if (
134 | // if i do not check for is_object( $polylang ), it gives $polylang as NULL
135 | // in short, these polylang methods not available to us while calling from plugin (not exopite framework)
136 | is_object( $polylang ) &&
137 | property_exists( $polylang, 'model' ) &&
138 | method_exists( $polylang->model, 'get_languages_list' )
139 | ) {
140 | $poly_langs = $polylang->model->get_languages_list();
141 | }
142 |
143 |
144 | if ( isset( $poly_langs ) && is_array( $poly_langs ) ) {
145 | foreach ( $poly_langs as $p_lang ) {
146 | $languages[ $p_lang->slug ] = $p_lang->slug;
147 | }
148 | }
149 |
150 |
151 | $multilang['default'] = $default;
152 | // When all languages selected, then $current is false, so make $current as $default
153 | $multilang['current'] = ( isset( $current ) && $current ) ? $current : $multilang['current'];
154 | $multilang['languages'] = ( isset( $languages ) && $languages ) ? $languages : $multilang['languages'];
155 |
156 | break; // case( 'polylang' )
157 |
158 | case( 'qtran' ):
159 | global $q_config;
160 | $multilang['default'] = $q_config['default_language'];
161 | $multilang['current'] = $q_config['language'];
162 | $multilang['languages'] = qtranxf_getSortedLanguages( false );
163 |
164 | break;
165 |
166 | case( 'wpm' ):
167 |
168 | $multilang['default'] = wpm_get_default_language();
169 | $multilang['current'] = wpm_get_user_language();
170 | $multilang['languages'] = array_keys( wpm_get_languages() );
171 |
172 | break;
173 |
174 | default:
175 |
176 | }
177 |
178 | }
179 |
180 |
181 | $multilang = apply_filters( 'exopite_sof_language_defaults', $multilang );
182 |
183 | return ( ! empty( $multilang ) ) ? $multilang : false;
184 |
185 | }
186 |
187 |
188 | public static function get_current_language_code() {
189 |
190 | $multilang = self::get_language_defaults();
191 |
192 | return $multilang['current'];
193 |
194 | }
195 |
196 | public static function get_default_language_code() {
197 |
198 | $multilang = self::get_language_defaults();
199 |
200 | return $multilang['default'];
201 |
202 | }
203 |
204 | }
205 |
206 | }
207 |
--------------------------------------------------------------------------------
/includes/api/ram-rest-live-controller.php:
--------------------------------------------------------------------------------
1 | namespace = 'watch-life-net/v1';
14 | $this->resource_name = 'live';
15 | }
16 |
17 | // Register our routes.
18 | public function register_routes() {
19 | register_rest_route( $this->namespace, '/' . $this->resource_name.'/refreshliveinfo', array(
20 | // Here we register the readable endpoint for collections.
21 | array(
22 | 'methods' => 'GET',
23 | 'callback' => array( $this, 'refreshliveinfo' ),
24 | 'args' => array(
25 | 'openid' => array(
26 | 'required' => true
27 | ),
28 | // 'userid' => array(
29 | // 'required' => true
30 | // )
31 | ),
32 | 'permission_callback' => array( $this, 'refresh_life_info_permissions_check' )
33 |
34 | ),
35 | // Register our schema callback.
36 | 'schema' => array( $this, 'get_public_item_schema' ),
37 | ) );
38 |
39 | register_rest_route( $this->namespace, '/' . $this->resource_name.'/getliveinfo', array(
40 | // Here we register the readable endpoint for collections.
41 | array(
42 | 'methods' => 'GET',
43 | 'callback' => array( $this, 'getliveinfo' ),
44 | 'permission_callback' => array( $this, 'getliveinfo_permissions_check' )
45 |
46 | ),
47 | // Register our schema callback.
48 | 'schema' => array( $this, 'get_public_item_schema' ),
49 | ) );
50 |
51 | }
52 |
53 | public function getliveinfo($request){
54 | $liveInfo_option =get_option('wf-liveInfo-option');
55 | $response = rest_ensure_response($liveInfo_option);
56 | return $response;
57 |
58 | }
59 |
60 | public function refreshliveinfo($request){
61 | $data = array(
62 | 'start' =>0,
63 | 'limit' =>10
64 |
65 | );
66 | $updateResult=true;
67 | $liveInfo = RAM()->wxapi->getliveinfo($data);
68 | $errcode=$liveInfo['errcode'];
69 | $errmsg=$liveInfo['errmsg'];
70 | if($errcode == 0 ) {
71 | if(!empty(get_option('wf-liveInfo-option')))
72 | {
73 | delete_option('wf-liveInfo-option');
74 | }
75 | $updateResult= update_option( 'wf-liveInfo-option', $liveInfo);
76 | $message=$updateResult?"更新成功":"更新失败";
77 | }
78 | else{
79 |
80 | if ($errcode==1 || $errcode==9410000)
81 | {
82 | if(!empty(get_option('wf-liveInfo-option')))
83 | {
84 | delete_option('wf-liveInfo-option');
85 | }
86 |
87 | $message="未创建直播间或直播间列表为空";
88 |
89 | }
90 | else
91 | {
92 | $message=$errmsg;
93 | }
94 |
95 |
96 | }
97 |
98 | $result = array('success' => $errcode ,'message'=>$message,'liveInfo'=>$liveInfo,'data'=>$data);
99 | $response = rest_ensure_response( $result );
100 | return $response;
101 |
102 | }
103 |
104 | /**
105 | * Check whether a given request has permission to read products.
106 | *
107 | * @param WP_REST_Request $request Full details about the request.
108 | * @return WP_Error|boolean
109 | */
110 | public function refresh_life_info_permissions_check( $request ) {
111 | $openId =$request['openid'];
112 | $user = get_user_by( 'login', $openId);
113 | if(empty($user))
114 | {
115 | return new WP_Error( 'error', '此用户不存在' , array( 'status' => 500 ) );
116 | }
117 | $userLevel= getUserLevel($user->ID);
118 | if( $userLevel['level'] !='10')
119 | {
120 | return new WP_Error( 'error', '没有权限' , array( 'status' => 500 ) );
121 |
122 | }
123 |
124 |
125 | return true;
126 | }
127 |
128 | /**
129 | * Check whether a given request has permission to read products.
130 | *
131 | * @param WP_REST_Request $request Full details about the request.
132 | * @return WP_Error|boolean
133 | */
134 | public function get_live_qrcode_permissions_check( $request ) {
135 | $roomid =isset($request['id'])?(int)$request['id']:0;
136 | if($roomid == 0)
137 | {
138 |
139 | return new WP_Error( 'error', '参数错误', array( 'status' => 400 ) );
140 |
141 | }
142 | return true;
143 | }
144 |
145 | public function getliveinfo_permissions_check($request)
146 | {
147 | return true;
148 | }
149 | }
150 |
--------------------------------------------------------------------------------
/includes/api/ram-rest-payment-controller.php:
--------------------------------------------------------------------------------
1 | namespace = 'watch-life-net/v1';
16 | $this->resource_name = 'payment';
17 | }
18 |
19 |
20 | // Register our routes.
21 | public function register_routes() {
22 |
23 | register_rest_route( $this->namespace, '/' . $this->resource_name, array(
24 | // Here we register the readable endpoint for collections.
25 | array(
26 | 'methods' => 'POST',
27 | 'callback' => array( $this, 'post_payment' ),
28 | 'permission_callback' => array( $this, 'post_payment_permissions_check' ),
29 | 'args' => array(
30 | 'openid' => array(
31 | 'required' => true
32 | ),
33 | 'totalfee' => array(
34 | 'required' => true
35 | )
36 |
37 | )
38 | ),
39 | // Register our schema callback.
40 | 'schema' => array( $this, 'post_public_item_schema' ),
41 | ) );
42 |
43 | register_rest_route( $this->namespace, '/' . $this->resource_name . '/notify', array(
44 | array(
45 | 'methods' => 'GET',
46 | 'callback' => array( $this, 'notify' ),
47 | 'permission_callback' => array( $this, 'get_notify_permissions_check' ),
48 | 'args' => $this->get_collection_params()
49 | )
50 | ) );
51 |
52 | }
53 |
54 | public function post_payment($request){
55 |
56 | date_default_timezone_set('Asia/Shanghai');
57 | $openId=isset($request['openid'])?$request['openid']:'';
58 | $totalFee=isset($request['totalfee'])? $request['totalfee']:1;
59 |
60 | if(!is_numeric($totalFee))
61 | {
62 |
63 | return new WP_Error( 'error', "totalfee参数错误", array( 'status' => 400 ) );
64 | }
65 |
66 |
67 | $appId=RAM_WxPayConfig::get_appid();
68 | $mchId=RAM_WxPayConfig::get_mchid();
69 | $key=RAM_WxPayConfig::get_key();
70 | $body=RAM_WxPayConfig::get_body();
71 |
72 | if(empty($appId) || empty($mchId) || empty($key) || empty($body)) {
73 |
74 | return new WP_Error( 'error', "请填写AppID、商户号、商户支付密钥和支付描述", array( 'status' => 400 ) );
75 | }
76 |
77 | $tools = new RAM_JsApiPay();
78 |
79 | //②、统一下单
80 | $input = new RAM_WxPayUnifiedOrder();
81 | $input->SetBody($body);
82 | $orderId =RAM_WxPayConfig::get_mchid().date("YmdHis");
83 | $input->SetOut_trade_no($orderId);
84 | $input->SetTotal_fee(strval($totalFee*100));
85 | //$input->SetTotal_fee(strval($totalFee));
86 | $input->SetTime_start(date("YmdHis"));
87 | $input->SetTime_expire(date("YmdHis", time() + 6000));
88 | $input->SetNotify_url(get_rest_url( null, $this->namespace . '/' . $this->resource_name . '/notify' ) );
89 | $input->SetTrade_type( 'JSAPI' );
90 | $input->SetOpenid($openId);
91 |
92 | $order = RAM_WxPayApi::unifiedOrder($input);
93 |
94 | $jsApiParameters = $tools->GetJsApiParameters($order);
95 |
96 | $jsApiParameters['success'] = 'success';
97 | return $jsApiParameters;
98 |
99 | }
100 |
101 | // 支付通知
102 | public function notify( $request ) {
103 |
104 | $notify = new RAW_PayNotifyCallBack();
105 | $notify->Handle( false );
106 | }
107 | public function post_payment_permissions_check($request) {
108 | $openId =isset($request['openid'])? $request['openid']:"";
109 | if(empty($openId) || !username_exists($openId))
110 | {
111 | return new WP_Error( 'user_parameter_error', "用户参数错误", array( 'status' => 400 ) );
112 | }
113 | $totalFee=isset($request['totalfee'])? (int)$request['totalfee']:1;
114 | if(!is_int($totalFee))
115 | {
116 | return new WP_Error( 'error', 'totalfee参数错误', array( 'status' => 400 ) );
117 | }
118 | return true;
119 | }
120 |
121 | /**
122 | * Check whether a given request has permission to read order notes.
123 | *
124 | * @param WP_REST_Request $request Full details about the request.
125 | * @return WP_Error|boolean
126 | */
127 | public function get_notify_permissions_check( $request ) {
128 | return true;
129 | }
130 |
131 |
132 | }
133 |
134 | class RAW_PayNotifyCallBack extends RAM_WxPayNotify {
135 |
136 | // 重写回调处理函数
137 | public function NotifyProcess( $data, &$msg ) {
138 |
139 | if( ! array_key_exists( 'transaction_id' , $data ) ) {
140 | $msg = '输入参数不正确';
141 | return false;
142 | }
143 | if(!RAW_Util::check_notify_sign($data,get_option('raw_paykey'))){
144 | $msg = 'key错误';
145 | return false;
146 | }
147 |
148 |
149 | return true;
150 | }
151 | }
--------------------------------------------------------------------------------
/includes/api/ram-rest-settings-controller.php:
--------------------------------------------------------------------------------
1 | namespace = 'watch-life-net/v1';
12 | $this->resource_name = 'options';
13 | }
14 |
15 | // Register our routes.
16 | public function register_routes() {
17 | register_rest_route( $this->namespace, '/' . $this->resource_name.'/enableComment', array(
18 | // Here we register the readable endpoint for collections.
19 | array(
20 | 'methods' => 'GET',
21 | 'callback' => array( $this, 'getEnableComment' ),
22 | 'permission_callback' => array( $this, 'get_item_permissions_check' )
23 |
24 | ),
25 | // Register our schema callback.
26 | 'schema' => array( $this, 'get_public_item_schema' ),
27 | ) );
28 |
29 | register_rest_route( $this->namespace, '/' . $this->resource_name, array(
30 | // Here we register the readable endpoint for collections.
31 | array(
32 | 'methods' => 'GET',
33 | 'callback' => array( $this, 'get_item' ),
34 | 'permission_callback' => array( $this, 'get_item_permissions_check' )
35 |
36 | ),
37 | // Register our schema callback.
38 | 'schema' => array( $this, 'get_public_item_schema' ),
39 | ) );
40 |
41 |
42 | register_rest_route( $this->namespace, '/' . $this->resource_name.'/homeconfig', array(
43 | // Here we register the readable endpoint for collections.
44 | array(
45 | 'methods' => 'GET',
46 | 'callback' => array( $this, 'get_homeconfig' ),
47 | 'permission_callback' => array( $this, 'get_item_permissions_check' ),
48 | ),
49 | // Register our schema callback.
50 | 'schema' => array( $this, 'get_public_item_schema' ),
51 | ) );
52 |
53 | }
54 |
55 | public function get_homeconfig($request)
56 | {
57 |
58 | $expand=get_option('minapper_expand_settings_page');
59 | $downloadfileDomain=get_option('wf_downloadfile_domain');
60 | $businessDomain=get_option('wf_business_domain');
61 | $result["downloadfileDomain"] =$downloadfileDomain;
62 | $result["businessDomain"] =$businessDomain;
63 |
64 | $zanImageurl=get_option('wf_zan_imageurl');
65 | $logoImageurl=get_option('wf_logo_imageurl');
66 | $postImageUrl=get_option("wf_poster_imageurl");
67 | $result["zanImageurl"] =$zanImageurl;
68 | $result["logoImageurl"] =$logoImageurl;
69 | $result["postImageUrl"] =$postImageUrl;
70 | $swipe_nav =$expand['swipe_nav'];
71 | $selected_nav=$expand['selected_nav'];
72 | $_expand['swipe_nav']=$swipe_nav;
73 | $_expand['selected_nav']=$selected_nav;
74 | $result["expand"] =$_expand;
75 | $appid=get_option('wf_appid');
76 | $result["appid"] =$appid;
77 | $history_post = get_history_post_list(date('Y'), date('m'), date('j'));
78 | $result["history_post"] =$history_post;
79 | $response = rest_ensure_response($result);
80 | return $response;
81 |
82 | }
83 | public function get_item($request)
84 | {
85 | $wf_enable_comment_option =empty(get_option('wf_enable_comment_option'))?"0":get_option('wf_enable_comment_option');
86 | $interstitialAdId =empty(get_option('wf_interstitial_ad_id'))?"":get_option('wf_interstitial_ad_id');
87 | $wf_enterprise_minapp =empty(get_option('wf_enterprise_minapp'))?"0":get_option('wf_enterprise_minapp');
88 |
89 | $enable_index_interstitial_ad =empty(get_option('enable_index_interstitial_ad'))?"0":get_option('enable_index_interstitial_ad');
90 | $enable_detail_interstitial_ad =empty(get_option('enable_detail_interstitial_ad'))?"0":get_option('enable_detail_interstitial_ad');
91 | $enable_topic_interstitial_ad =empty(get_option('enable_topic_interstitial_ad'))?"0":get_option('enable_topic_interstitial_ad');
92 | $enable_list_interstitial_ad =empty(get_option('enable_list_interstitial_ad'))?"0":get_option('enable_list_interstitial_ad');
93 | $enable_hot_interstitial_ad =empty(get_option('enable_hot_interstitial_ad'))?"0":get_option('enable_hot_interstitial_ad');
94 | $enable_comments_interstitial_ad =empty(get_option('enable_comments_interstitial_ad'))?"0":get_option('enable_comments_interstitial_ad');
95 | $enable_live_interstitial_ad =empty(get_option('enable_live_interstitial_ad'))?"0":get_option('enable_comments_interstitial_ad');
96 |
97 |
98 | $result["enable_index_interstitial_ad"]=$enable_index_interstitial_ad;
99 | $result["enable_detail_interstitial_ad"]=$enable_detail_interstitial_ad;
100 | $result["enable_topic_interstitial_ad"]=$enable_topic_interstitial_ad;
101 | $result["enable_list_interstitial_ad"]=$enable_list_interstitial_ad;
102 | $result["enable_hot_interstitial_ad"]=$enable_hot_interstitial_ad;
103 | $result["enable_comments_interstitial_ad"]=$enable_comments_interstitial_ad;
104 | $result["enable_live_interstitial_ad"]=$enable_live_interstitial_ad;
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 | $result["wf_enable_comment_option"]=$wf_enable_comment_option;
113 | $result["interstitialAdId"]=$interstitialAdId;
114 | $result["wf_enterprise_minapp"]=$wf_enterprise_minapp;
115 | $response = rest_ensure_response( $result);
116 | return $response;
117 | }
118 |
119 | public function getEnableComment($request)
120 | {
121 | $wf_enable_comment_option =get_option('wf_enable_comment_option');
122 | $interstitial_ad_id =get_option('wf_interstitial_ad_id');
123 | if(empty($wf_enable_comment_option ))
124 | {
125 | $result["code"]="success";
126 | $result["message"]= "获取是否开启评论成功";
127 | $result["status"]="200";
128 | $result["enableComment"]="0";
129 | }
130 | else
131 | {
132 | $result["code"]="success";
133 | $result["message"]= "获取是否开启评论成功";
134 | $result["status"]="200";
135 | $result["enableComment"]="1";
136 |
137 | }
138 | $response = rest_ensure_response( $result);
139 | return $response;
140 | }
141 |
142 |
143 | public function get_item_permissions_check($request ) {
144 |
145 | return true;
146 | }
147 |
148 |
149 |
150 | }
--------------------------------------------------------------------------------
/includes/css/gallery.css:
--------------------------------------------------------------------------------
1 | .gallery-container {
2 | max-width: 1200px;
3 | margin: 2rem auto;
4 | padding: 20px;
5 | border: 3px solid #e0e0e0;
6 | border-radius: 15px;
7 | box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
8 | position: relative;
9 | overflow: hidden;
10 | }
11 |
12 | .gallery-viewport {
13 | position: relative;
14 | overflow: hidden;
15 | }
16 |
17 | .slides-container {
18 | display: flex;
19 | transition: transform 0.5s ease;
20 | }
21 |
22 | .slide {
23 | flex: 0 0 100%;
24 | max-width: 100%;
25 | min-height: 400px;
26 | display: flex;
27 | justify-content: center;
28 | align-items: center;
29 | padding: 15px;
30 | box-sizing: border-box;
31 | }
32 |
33 | .slide img {
34 | max-width: 100%;
35 | max-height: 80vh;
36 | object-fit: contain;
37 | border-radius: 8px;
38 | box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
39 | }
40 |
41 | .navigation-dots {
42 | position: absolute;
43 | bottom: 20px;
44 | left: 50%;
45 | transform: translateX(-50%);
46 | display: flex;
47 | gap: 12px;
48 | }
49 |
50 | .dot {
51 | width: 14px;
52 | height: 14px;
53 | border-radius: 50%;
54 | background: #ccc;
55 | cursor: pointer;
56 | transition: background 0.3s ease;
57 | }
58 |
59 | .dot.active {
60 | background: #000;
61 | }
62 |
63 | .nav-button {
64 | position: absolute;
65 | top: 50%;
66 | transform: translateY(-50%);
67 | background: rgba(0, 0, 0, 0.6);
68 | color: white;
69 | border: none;
70 | padding: 12px 18px;
71 | border-radius: 5px;
72 | cursor: pointer;
73 | font-size: 1.2rem;
74 | transition: background 0.3s ease;
75 | }
76 |
77 | .nav-button:hover {
78 | background: rgba(0, 0, 0, 0.8);
79 | }
80 |
81 | .prev {
82 | left: 20px;
83 | }
84 |
85 | .next {
86 | right: 20px;
87 | }
88 |
89 | @media (max-width: 768px) {
90 | .gallery-container {
91 | margin: 1rem;
92 | padding: 10px;
93 | }
94 |
95 | .slide {
96 | min-height: 300px;
97 | }
98 |
99 | .nav-button {
100 | padding: 8px 12px;
101 | font-size: 1rem;
102 | }
103 | }
--------------------------------------------------------------------------------
/includes/css/menu.css:
--------------------------------------------------------------------------------
1 | @charset "UTF-8";
2 | @font-face {font-family: "iconfont";
3 | src: url('//at.alicdn.com/t/font_2380172_x6l3odtoauc.eot?t=1613952382449'); /* IE9 */
4 | src: url('//at.alicdn.com/t/font_2380172_x6l3odtoauc.eot?t=1613952382449#iefix') format('embedded-opentype'), /* IE6-IE8 */
5 | url('data:application/x-font-woff2;charset=utf-8;base64,d09GMgABAAAAAALkAAsAAAAABsAAAAKYAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHEIGVgCCcAqBTIFFATYCJAMICwYABCAFhG0HLhvpBcgOJc2QwIAjgEBFBPHLn7Pv3n2OVlWtEt917Q6F8KDpwuKaESQRLtHR3Yh/taab+S+DardEIVlkBege7hO+zOXKaIl8FfkKx6BIVZLr/xwzXQJl/+d7c8kO2hvgeEADqosMsjuQQ79h7IIXeDOBJoNy6daqG1vAX2bvFYgrm0UC/0JUllmhEmoNJ2aIZ6UqzadjAE/R78d/MIc/SMoC7JbNyyoVSn9lOiXCWH0MTgOEGAGdXqLAPJCJ3cbsOkEwnKApKxoFx2oMfmX+1wO7OKpFsH+dXd8C+qH0mWSe/FEFE8jUswTsI2z+sqIlKEu6/Wi7+2y/eW+9fhtY+hK/vnv3ERvfpPH329ce2Dpf+JGgy7DQKyUvNzd3JUd4xV3K//WDiCg+OGZEX4kfErLYldSTKqxPrUen9hQ8hrcmVYUtN68drDUfAhq2hh+Sl9urklbsBJR2udLtiY2NWBSJkDHgPH8m+D7s93cRVvhdNYsAPztjR9Au9TERihtUp/UFv082cCobCtuWsiZrLCZLhNsaaNKEOuBgl9epxt57dYeqIGOQNBiAQmUcmbHzUGq2ADWVRWgyp+b0Zt0YQeQAYNY0gNBhD5I2n1DocILM2Bco9fmCmo4QoMl+RF2w2WTYAisYkThRUe5Hm0LdmuvggXFjE7F0OyWWV0TsNsK8tgSa9MZyoYa4CVviEG+Pxcy5hhqjLqwGtyNOJ0UPo3aicL2Vc0++waA1fZNeoS4ItIohJByhQrJ+yEZBuWnBfC6w8vNNCItuThLWMVEXbkMwXrblkYmecQCyRuseNPEor/HqYWHGcRqkYSgXVA22EU5OFPI0b7MjFJyedULaI5/BmaUN1eq317v+7gI0sU0pnE4B8hW1UAA=') format('woff2'),
6 | url('//at.alicdn.com/t/font_2380172_x6l3odtoauc.woff?t=1613952382449') format('woff'),
7 | url('//at.alicdn.com/t/font_2380172_x6l3odtoauc.ttf?t=1613952382449') format('truetype'), /* chrome, firefox, opera, Safari, Android, iOS 4.2+ */
8 | url('//at.alicdn.com/t/font_2380172_x6l3odtoauc.svg?t=1613952382449#iconfont') format('svg'); /* iOS 4.1- */
9 | }
10 |
11 | #adminmenu #toplevel_page_weixinapp_slug .dashicons-before::before {
12 | font-family: iconfont !important;
13 | content: '\e628'
14 | }
--------------------------------------------------------------------------------
/includes/filter/ram-custom-category-rows.php:
--------------------------------------------------------------------------------
1 | term_id;
12 | if(empty($subscription))
13 | {
14 | $data->data['subimg'] ="subscription.png";
15 | $data->data['subflag'] ="0";
16 | }
17 | else
18 | {
19 | if(array_search($id,$subscription ))
20 | {
21 | $data->data['subimg'] ="subscription-on.png";
22 | $data->data['subflag'] ="1";
23 | }
24 | else
25 | {
26 | $data->data['subimg'] ="subscription.png";
27 | $data->data['subflag'] ="0";
28 |
29 | }
30 | }
31 |
32 |
33 | if($temp=get_term_meta($item->term_id,'catcover',true))
34 | {
35 | $category_thumbnail_image=$temp;
36 |
37 | }
38 | elseif($temp=get_term_meta($item->term_id,'thumbnail',true));
39 | {
40 | $category_thumbnail_image=$temp;
41 | }
42 |
43 | $data->data['category_thumbnail_image'] =$category_thumbnail_image;
44 | return $data;
45 | }
46 |
47 | function getSubscription($openid)
48 | {
49 | global $wpdb;
50 | $user_id =0;
51 | $user = get_user_by('login', $openid);
52 | $subscription= array();
53 | if($user)
54 | {
55 | $user_id = $user->ID;
56 | $usermeta = get_user_meta($user_id);
57 | if (!empty($usermeta))
58 | {
59 | if(!empty($usermeta['wl_sub']))
60 | {
61 | $subscription=$usermeta['wl_sub'];
62 | }
63 | }
64 |
65 | }
66 | return $subscription;
67 |
68 | }
69 |
70 |
71 |
72 |
73 |
74 | /********* 给分类添加微信小程序封面 *********/
75 |
76 | add_action( 'category_add_form_fields', 'weixin_new_term_catcover_field' );
77 | function weixin_new_term_catcover_field() {
78 | wp_nonce_field( basename( __FILE__ ), 'weixin_app_term_catcover_nonce' );
79 |
80 | ?>
81 |
82 |
86 | term_id, 'catcover', true );
93 | if ( function_exists( 'wp_enqueue_media' ) ) {
94 | wp_enqueue_media();
95 | }
96 | wp_enqueue_script('rawscript', plugins_url().'/'.REST_API_TO_MINIPROGRAM_PLUGIN_NAME.'/includes/js/script.js', false, '1.0');
97 | if ( ! $catcover )
98 | $catcover = $default; ?>
99 |
100 |
101 | |
102 |
103 |
104 |
105 |
106 | |
107 |
108 | data;
6 | $user_id=(int)$comment->user_id;
7 | if($user_id==0)
8 | {
9 | $_data['author_url']=plugins_url() . '/' . REST_API_TO_MINIPROGRAM_PLUGIN_NAME . '/includes/images/gravatar.png';
10 | }
11 | else
12 | {
13 | $_data['author_url']= get_user_meta($user_id, 'avatar', true );
14 | }
15 |
16 | $data->data = $_data;
17 | return $data;
18 | }
19 |
20 |
21 |
--------------------------------------------------------------------------------
/includes/filter/ram-custom-content.php:
--------------------------------------------------------------------------------
1 | post_excerpt) ? "" : $post->post_excerpt;
22 | if (strlen($excerpt) < 1 && strlen($_content) > 0) {
23 | $excerpt = ram_rewrite_content($_content, 500);
24 | }
25 | $message='';
26 | if (is_single()) {
27 | $message = '微信扫描下方的二维码阅读本文
';
28 | if ($excitationAd == '1') {
29 | $message = '微信扫描下方的二维码阅读全文
';
30 | $_content = $excerpt;
31 | }
32 |
33 | if($display_qrcode == '1')
34 | {
35 |
36 | $qrcode=creat_minapper_qrcode($postId);
37 | $qrcode=$qrcode['qrcodeUrl'];
38 | $qrcode = "

";
39 | // $path = "pages/detail/detail?id=" . $postId;
40 | // $url = get_option('siteurl') . '/wp-json/watch-life-net/v1/weixin/qrcodeimg?postid=' . $postId . '&path=' . $path;
41 | // $qrcode = "";
42 | // $response = wp_remote_get($url);
43 | // if (is_array($response) && !is_wp_error($response) && $response['response']['code'] == '200') {
44 |
45 | // $body = json_decode($response['body'], true);
46 | // $qrcode = "

";
47 |
48 | // }
49 | // else{
50 | // $qrcode = "

";
51 | // }
52 | $_content .= "
" . $message . $qrcode . "
";
53 | }
54 | else
55 | {
56 | if ($excitationAd == '1') {
57 | $message = '微信扫描下方的二维码阅读本文
';
58 | $qrcode = "

";
59 | $_content .= "
" . $message . $qrcode . "
";
60 |
61 | }
62 |
63 | }
64 |
65 |
66 | }
67 | return $_content;
68 | }
69 |
--------------------------------------------------------------------------------
/includes/filter/ram-custom-posts-rows.php:
--------------------------------------------------------------------------------
1 |

";
38 | } else {
39 | // 否则显示占位符或提示信息
40 | echo '
暂未生成';
41 | }
42 | }
43 |
44 | }
45 |
46 |
47 | function ram_pages_columns( $columns ) {
48 | $columns['id'] = __('id');
49 | return $columns;
50 | }
51 |
52 | function output_ram_pages_custom_columns( $column,$post_id)
53 | {
54 | if($column=='id') echo $post_id;
55 |
56 | }
57 |
58 | function ram_posts_custom_bulk_actions( $bulk_array ) {
59 | $bulk_array['creat_post_qrcode'] = '生成小程序码';
60 | $bulk_array['enable_post_excitation'] = '启用激励视频';
61 | $bulk_array['cancel_post_excitation'] = '取消激励视频';
62 | return $bulk_array;
63 | }
64 |
65 | function ram_posts_custom_bulk_actions_handler($redirect, $doaction, $object_ids)
66 | {
67 | if ( $doaction == 'creat_post_qrcode' ){
68 | foreach ( $object_ids as $post_id ) {
69 | creat_minapper_qrcode($post_id);
70 | }
71 | $redirect = add_query_arg( 'ram_post_custom_bulk_actions', count( $object_ids ), $redirect );
72 | }
73 |
74 | if ( $doaction == 'enable_post_excitation' ){
75 | foreach ( $object_ids as $post_id ) {
76 | update_post_meta($post_id,'_excitation','1');
77 | }
78 | $redirect = add_query_arg( 'ram_post_custom_bulk_actions', count( $object_ids ), $redirect );
79 | }
80 |
81 | if ( $doaction == 'cancel_post_excitation' ){
82 | foreach ( $object_ids as $post_id ) {
83 | update_post_meta($post_id,'_excitation','0');
84 | }
85 | $redirect = add_query_arg( 'ram_post_custom_bulk_actions', count( $object_ids ), $redirect );
86 | }
87 |
88 |
89 | return $redirect;
90 |
91 | }
92 |
93 | add_action( 'admin_notices', 'ram_post_custom_bulk_actions_notices' );
94 |
95 | function ram_post_custom_bulk_actions_notices() {
96 | // 改为草稿
97 | if ( ! empty( $_REQUEST['ram_post_custom_bulk_actions'] ) ) {
98 | echo '
';
101 | }
102 | }
103 |
104 |
105 |
--------------------------------------------------------------------------------
/includes/filter/ram-custom-users-columns.php:
--------------------------------------------------------------------------------
1 | query_orderby = "ORDER BY user_registered ".$_REQUEST['order']."";
32 | }
33 | }
34 | function getRegisteredDate($userId)
35 | {
36 | $user=get_user_by('ID',$userId);
37 | $resutlt =$user->user_registered;
38 | return $resutlt;
39 | }
40 |
41 | function getAvatar($userId)
42 | {
43 | $avatar= get_user_meta( $userId, 'avatar', true );
44 | if(empty($avatar))
45 | {
46 | $avatarImg ='
.'/'.REST_API_TO_MINIPROGRAM_PLUGIN_NAME.'/includes/images/gravatar.png)
';
47 | }
48 | else{
49 | $avatarImg ='

';
50 |
51 | }
52 |
53 | return $avatarImg;
54 |
55 | }
--------------------------------------------------------------------------------
/includes/images/gravatar.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iamxjb/rest-api-to-miniprogram/c6c74b19237dbe8a2c815b4f78d5e829ac2485aa/includes/images/gravatar.png
--------------------------------------------------------------------------------
/includes/images/icon16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iamxjb/rest-api-to-miniprogram/c6c74b19237dbe8a2c815b4f78d5e829ac2485aa/includes/images/icon16.png
--------------------------------------------------------------------------------
/includes/images/minapper-plus.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iamxjb/rest-api-to-miniprogram/c6c74b19237dbe8a2c815b4f78d5e829ac2485aa/includes/images/minapper-plus.jpg
--------------------------------------------------------------------------------
/includes/images/minapper-pro.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iamxjb/rest-api-to-miniprogram/c6c74b19237dbe8a2c815b4f78d5e829ac2485aa/includes/images/minapper-pro.jpg
--------------------------------------------------------------------------------
/includes/images/qrcode.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iamxjb/rest-api-to-miniprogram/c6c74b19237dbe8a2c815b4f78d5e829ac2485aa/includes/images/qrcode.jpg
--------------------------------------------------------------------------------
/includes/images/rest-api-to-miniprogram.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iamxjb/rest-api-to-miniprogram/c6c74b19237dbe8a2c815b4f78d5e829ac2485aa/includes/images/rest-api-to-miniprogram.png
--------------------------------------------------------------------------------
/includes/js/gallery.js:
--------------------------------------------------------------------------------
1 | class Gallery {
2 | constructor(container, options = {}) {
3 | this.container = container;
4 | this.options = {
5 | autoplay: true,
6 | interval: 5000,
7 | ...options
8 | };
9 | this.slidesContainer = container.querySelector('.slides-container');
10 | this.slides = Array.from(container.querySelectorAll('.slide'));
11 | this.currentIndex = 0;
12 | this.touchStartX = 0;
13 | this.isDragging = false;
14 | this.autoPlayTimer = null;
15 |
16 | this.init();
17 | }
18 |
19 | init() {
20 | this.createNavigationDots();
21 | this.setupEventListeners();
22 | this.goTo(0);
23 | this.lazyLoad = new LazyLoader();
24 | this.lazyLoad.observe(this.slides);
25 |
26 | if (this.options.autoplay) {
27 | this.startAutoPlay();
28 | }
29 | }
30 |
31 | createNavigationDots() {
32 | const dotsContainer = this.container.querySelector('.navigation-dots');
33 | this.dots = this.slides.map((_, index) => {
34 | const dot = document.createElement('div');
35 | dot.className = 'dot';
36 | dot.addEventListener('click', () => this.goTo(index));
37 | dotsContainer.appendChild(dot);
38 | return dot;
39 | });
40 | }
41 |
42 | updateNavigation() {
43 | this.dots.forEach((dot, index) => {
44 | dot.classList.toggle('active', index === this.currentIndex);
45 | });
46 | }
47 |
48 | goTo(index) {
49 | if (index < 0 || index >= this.slides.length) return;
50 | this.currentIndex = index;
51 | this.slidesContainer.style.transform = `translateX(-${index * 100}%)`;
52 | this.updateNavigation();
53 | }
54 |
55 | next() {
56 | const newIndex = (this.currentIndex + 1) % this.slides.length;
57 | this.goTo(newIndex);
58 | }
59 |
60 | prev() {
61 | const newIndex = (this.currentIndex - 1 + this.slides.length) % this.slides.length;
62 | this.goTo(newIndex);
63 | }
64 |
65 | handleTouchStart(e) {
66 | this.touchStartX = e.touches[0].clientX;
67 | this.isDragging = true;
68 | }
69 |
70 | handleTouchMove(e) {
71 | if (!this.isDragging) return;
72 | const touchEndX = e.touches[0].clientX;
73 | const diff = this.touchStartX - touchEndX;
74 |
75 | if (Math.abs(diff) > 50) {
76 | this.isDragging = false;
77 | diff > 0 ? this.next() : this.prev();
78 | }
79 | }
80 |
81 | setupEventListeners() {
82 | this.container.querySelector('.prev').addEventListener('click', () => this.prev());
83 | this.container.querySelector('.next').addEventListener('click', () => this.next());
84 |
85 | // 触摸事件
86 | this.slidesContainer.addEventListener('touchstart', e => this.handleTouchStart(e));
87 | this.slidesContainer.addEventListener('touchmove', e => this.handleTouchMove(e));
88 |
89 | // 窗口尺寸变化重置位置
90 | window.addEventListener('resize', () => this.goTo(this.currentIndex));
91 | }
92 |
93 | startAutoPlay() {
94 | this.autoPlayTimer = setInterval(() => this.next(), this.options.interval);
95 |
96 | // 鼠标悬停时暂停
97 | this.container.addEventListener('mouseenter', () => clearInterval(this.autoPlayTimer));
98 | this.container.addEventListener('mouseleave', () => this.startAutoPlay());
99 | }
100 | }
101 |
102 | class LazyLoader {
103 | constructor() {
104 | this.observer = new IntersectionObserver((entries) => {
105 | entries.forEach(entry => {
106 | if (entry.isIntersecting) {
107 | this.loadImage(entry.target);
108 | this.observer.unobserve(entry.target);
109 | }
110 | });
111 | }, {
112 | rootMargin: '200px',
113 | threshold: 0.01
114 | });
115 | }
116 |
117 | observe(slides) {
118 | slides.forEach(slide => {
119 | this.observer.observe(slide);
120 | });
121 | }
122 |
123 | loadImage(slide) {
124 | const img = slide.querySelector('img');
125 | if (!img.dataset.src) return;
126 | img.src = img.dataset.src;
127 | delete img.dataset.src;
128 | }
129 | }
130 |
131 | // 初始化画廊
132 | document.addEventListener('DOMContentLoaded', () => {
133 | const gallery = new Gallery(document.querySelector('.gallery-container'), {
134 | autoplay: true,
135 | interval: 5000
136 | });
137 | });
--------------------------------------------------------------------------------
/includes/js/script.js:
--------------------------------------------------------------------------------
1 | jQuery(document).ready(function($) {
2 |
3 | //选择媒体库
4 | $('body').on("click", '.im-upload', function(e) {
5 | e.preventDefault(); // 阻止事件默认行为。
6 | var upload = $(this).prev("input");
7 | var type = $(this).data('type');
8 | var title = (type == 'image')?'选择图片':'选择媒体';
9 |
10 | uploader = wp.media({
11 | title: title,
12 | library: { type: type },
13 | button: { text: title },
14 | multiple: false
15 | }).on('select', function() {
16 | var attachment = uploader.state().get('selection').first().toJSON();
17 | upload.val(attachment.url);
18 | $('.media-modal-close').trigger('click');
19 | }).open();
20 | return false;
21 | });
22 |
23 |
24 |
25 | })
--------------------------------------------------------------------------------
/includes/js/tab/tabs.css:
--------------------------------------------------------------------------------
1 | /* REQUIRED for core functionality */
2 | .responsive-tabs__heading { display: none;}
3 | .responsive-tabs__list__item { display: inline; cursor:pointer;}
4 | @media (max-width: 767px) {
5 | .responsive-tabs__list { display: none;}
6 | .responsive-tabs__heading { display: block; cursor: pointer; }
7 | .responsive-tabs__panel--closed-accordion-only { display: none;}
8 | }
9 | @media (min-width: 768px) {
10 | .responsive-tabs__panel--closed-accordion-only { display: block !important;}
11 | }
12 | /* END - Required for core functionality */
13 | /* OPTIONAL - Basic Skin */
14 | .responsive-tabs-wrapper {
15 | clear: both;
16 | zoom: 1;
17 | }
18 | .responsive-tabs-wrapper:before,
19 | .responsive-tabs-wrapper:after {
20 | content: "";
21 | display: table;
22 | }
23 | .responsive-tabs-wrapper:after {
24 | clear: both;
25 | }
26 | .responsive-tabs__heading:focus,
27 | .responsive-tabs__list__item:focus { outline: 1px solid #ccc; }
28 | .responsive-tabs__heading--active:focus,
29 | .responsive-tabs__list__item--active:focus { outline: none !important;}
30 | .responsive-tabs__list { font-size: 1.2em; margin: 2em 0 0 0; border-bottom: 1px solid #ddd; padding-top: 0; padding-left:0; padding-right:0; padding-bottom:13px; line-height: 1em;}
31 | .responsive-tabs__list__item { background: #eee; padding: 10px 20px; margin-right: 1em; border-top-left-radius: 5px; border-top-right-radius: 5px;border: 1px solid #ddd; }
32 | .responsive-tabs__list__item:hover {background: #efefef }
33 | .responsive-tabs__list__item--active,
34 | .responsive-tabs__list__item--active:hover { background: #fff; border-bottom-color: #fff;}
35 | .responsive-tabs__panel { background:#fff; margin-top:-1px; padding:20px; border-left: 1px solid #ddd; border-right: 1px solid #ddd; border-top: 1px solid #ddd; border-bottom: 1px solid #ddd;}
36 | @media (min-width: 768px) {
37 | .responsive-tabs__list, .responsive-tabs__panel {
38 | width:95%;
39 | }
40 | }
41 | @media (max-width: 767px) {
42 | .responsive-tabs__heading {
43 | padding: 0.5em; border-radius: 5px; border: 1px solid #ccc; box-shadow: 0px 2px 3px rgba(0,0,0,0.4);
44 | background: #ddd;
45 | position: relative;
46 | }
47 | .responsive-tabs__heading:after {
48 | content:"";
49 | display: block;
50 | position: absolute;
51 | right: 20px;
52 | top: 40%;
53 | width: 0;
54 | height: 0;
55 | border-left: 10px solid transparent;
56 | border-right: 10px solid transparent;
57 | border-top: 10px solid #000;
58 | }
59 | .responsive-tabs__heading:hover,
60 | .responsive-tabs__heading--active:hover { background-color: #efefef}
61 | .responsive-tabs__heading--active { background: #fff;}
62 | .responsive-tabs__heading--active:after {
63 | border-bottom: 10px solid #000;
64 | border-top:0;
65 | }
66 | }
67 | /* END - Optional - Basic Skin */
68 | .option .imglink {
69 | width:80%;
70 | max-width:600px;
71 | }
72 | .option .intext {
73 | width:60%;
74 | max-width:400px;
75 | }
76 | .option select {
77 | width:160px;
78 | }
79 | .option textarea {
80 | width:80%;
81 | max-width:600px;
82 | min-height:180px;
83 | }
84 | .wrap .dashicons-admin-settings {
85 | color: #0073aa;
86 | font-size: 30px;
87 | margin: 3px 15px 0 0;
88 | }
89 | .wrap .version {
90 | background: #555;
91 | color: #fff;
92 | font-size: 12px;
93 | margin: 0 0 0 10px;
94 | padding: 1px 8px;
95 | border-radius: 2px;
96 | box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
97 | }
98 | .wrap .clearfix {
99 | margin-top: 20px;
100 | margin-left:-20px;
101 | margin-right:-20px;
102 | padding: 0;
103 | /* border-top: 1px solid #e5e5e5; */
104 | }
105 | .wrap .hide {
106 | display:none!important;
107 | }
--------------------------------------------------------------------------------
/includes/js/tab/tabs.min.js:
--------------------------------------------------------------------------------
1 | // ResponsiveTabs.js | Version:1.10 | Author:Pete Love | www.petelove.com
2 | var RESPONSIVEUI={};(function($){RESPONSIVEUI.responsiveTabs=function(){var $tabSets=$(".responsive-tabs");if(!$tabSets.hasClass("responsive-tabs--enabled")){$tabSets.addClass("responsive-tabs--enabled");var tablistcount=1;$tabSets.each(function(){var $tabs=$(this);$tabs.children(":header").addClass("responsive-tabs__heading");$tabs.children("div").addClass("responsive-tabs__panel");var $activePanel=$tabs.find(".responsive-tabs__panel--active");if(!$activePanel.length){$activePanel=$tabs.find(".responsive-tabs__panel").first().addClass("responsive-tabs__panel--active")}$tabs.find(".responsive-tabs__panel").not(".responsive-tabs__panel--active").hide().attr("aria-hidden","true");$activePanel.attr("aria-hidden","false");$activePanel.addClass("responsive-tabs__panel--closed-accordion-only");var $tabsWrapper=$("
",{"class":"responsive-tabs-wrapper"});$tabs.wrap($tabsWrapper);var highestHeight=0;$tabs.find(".responsive-tabs__panel").each(function(){var tabHeight=$(this).height();if(tabHeight>highestHeight){highestHeight=tabHeight}});var $tabList=$("
",{"class":"responsive-tabs__list",role:"tablist"});var tabcount=1;$tabs.find(".responsive-tabs__heading").each(function(){var $tabHeading=$(this);var $tabPanel=$(this).next();$tabHeading.attr("tabindex",0);var $tabListItem=$("
",{"class":"responsive-tabs__list__item",id:"tablist"+tablistcount+"-tab"+tabcount,"aria-controls":"tablist"+tablistcount+"-panel"+tabcount,role:"tab",tabindex:0,text:$tabHeading.text(),keydown:function(objEvent){if(objEvent.keyCode===13){$tabListItem.click()}},click:function(){$tabsWrapper.css("height",highestHeight);$tabs.find(".responsive-tabs__panel--closed-accordion-only").removeClass("responsive-tabs__panel--closed-accordion-only");$tabs.find(".responsive-tabs__panel--active").toggle().removeClass("responsive-tabs__panel--active").attr("aria-hidden","true").prev().removeClass("responsive-tabs__heading--active");$tabPanel.toggle().addClass("responsive-tabs__panel--active").attr("aria-hidden","false");$tabHeading.addClass("responsive-tabs__heading--active");$tabList.find(".responsive-tabs__list__item--active").removeClass("responsive-tabs__list__item--active");$tabListItem.addClass("responsive-tabs__list__item--active");$tabsWrapper.css("height","auto")}});$tabPanel.attr({role:"tabpanel","aria-labelledby":$tabListItem.attr("id"),id:"tablist"+tablistcount+"-panel"+tabcount});if($tabPanel.hasClass("responsive-tabs__panel--active")){$tabListItem.addClass("responsive-tabs__list__item--active")}$tabList.append($tabListItem);$tabHeading.keydown(function(objEvent){if(objEvent.keyCode===13){$tabHeading.click()}});$tabHeading.click(function(){$tabs.find(".responsive-tabs__panel--closed-accordion-only").removeClass("responsive-tabs__panel--closed-accordion-only");if(!$tabHeading.hasClass("responsive-tabs__heading--active")){var oldActivePos,$activeHeading=$tabs.find(".responsive-tabs__heading--active");if($activeHeading.length){oldActivePos=$activeHeading.offset().top}$tabs.find(".responsive-tabs__panel--active").slideToggle().removeClass("responsive-tabs__panel--active").prev().removeClass("responsive-tabs__heading--active");$tabs.find(".responsive-tabs__panel").hide().attr("aria-hidden","true");$tabPanel.slideToggle().addClass("responsive-tabs__panel--active").attr("aria-hidden","false");$tabHeading.addClass("responsive-tabs__heading--active");var $currentActive=$tabs.find(".responsive-tabs__list__item--active");$currentActive.removeClass("responsive-tabs__list__item--active");var panelId=$tabPanel.attr("id");var tabId=panelId.replace("panel","tab");$("#"+tabId).addClass("responsive-tabs__list__item--active");var tabsPos=$tabs.offset().top;var newActivePos=($tabHeading.offset().top)-15;if(oldActivePos
rest_api_init();
15 | }
16 |
17 | /**
18 | * Init WP REST API.
19 | * @since 2.6.0
20 | */
21 | private function rest_api_init() {
22 | global $wp_version;
23 |
24 | // REST API was included starting WordPress 4.4.
25 | // if ( version_compare( $wp_version, 4.4, '<' ) ) {
26 | // return;
27 | // }
28 |
29 | $this->rest_api_includes();
30 |
31 | // Init REST API routes.
32 | add_action( 'rest_api_init', array( $this, 'register_rest_routes' ) );
33 | }
34 |
35 | /**
36 | * Include REST API classes.
37 | * @since 2.6.0
38 | */
39 | private function rest_api_includes() {
40 | include_once( 'api/ram-rest-posts-controller.php' );
41 | include_once( 'api/ram-rest-comments-controller.php' );
42 | include_once( 'api/ram-rest-weixin-controller.php' );
43 | include_once( 'api/ram-rest-settings-controller.php' );
44 | include_once( 'api/ram-rest-payment-controller.php' );
45 | include_once( 'api/ram-rest-categories-controller.php' );
46 | include_once( 'api/ram-rest-live-controller.php' );
47 | include_once( 'api/ram-wp-rest-posts-controller.php' );
48 | include_once( 'api/ram-rest-attachments-controller.php' );
49 | }
50 |
51 | /**
52 | * Register REST API routes.
53 | * @since 2.6.0
54 | */
55 | public function register_rest_routes() {
56 | $controllers = array(
57 | 'RAM_REST_Posts_Controller',
58 | 'RAM_REST_Weixin_Controller',
59 | 'RAM_REST_Comments_Controller',
60 | 'RAM_REST_Options_Controller',
61 | 'RAW_REST_Payment_Controller',
62 | 'RAM_REST_Categories_Controller',
63 | 'RAM_WP_REST_Posts_Controller',
64 | 'RAM_REST_Live_Controller',
65 | 'RAM_REST_Attachments_Controller'
66 |
67 |
68 | );
69 |
70 | foreach ( $controllers as $controller ) {
71 | $this->$controller = new $controller();
72 | $this->$controller->register_routes();
73 | }
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/includes/ram-weixin-api.php:
--------------------------------------------------------------------------------
1 | $result['access_token'],
32 | 'expire_time' => time() + intval( $result['expires_in'])-300
33 | );
34 | update_option( 'ram-access_token', $access_token );
35 | return $access_token['access_token'];
36 | }
37 | }
38 |
39 | return false;
40 | }
41 |
42 | // 获取微信公众平台API地址
43 | public function API( $key) {
44 |
45 |
46 | $api_urls = array(
47 | 'all_template' => 'https://api.weixin.qq.com/cgi-bin/wxopen/template/library/list',
48 | 'my_template' => 'https://api.weixin.qq.com/cgi-bin/wxopen/template/list',
49 | 'get_template_keywords' => 'https://api.weixin.qq.com/cgi-bin/wxopen/template/library/get',
50 | 'add_template' => 'https://api.weixin.qq.com/cgi-bin/wxopen/template/add',
51 | 'delete_template' => 'https://api.weixin.qq.com/cgi-bin/wxopen/template/del',
52 | 'send_template' => 'https://api.weixin.qq.com/cgi-bin/message/wxopen/template/send',
53 | 'msgSecCheck'=>'https://api.weixin.qq.com/wxa/msg_sec_check',
54 | 'getliveinfo'=>'https://api.weixin.qq.com/wxa/business/getliveinfo',
55 | 'get_qrcode' => 'https://api.weixin.qq.com/wxa/getwxacode',
56 | 'get_callbackip' => 'https://api.weixin.qq.com/cgi-bin/getcallbackip',
57 | 'get_miniprogram_cooperation_shop_list'=>'https://api.weixin.qq.com/channels/ec/cooperation/shop/list'
58 | );
59 |
60 | return $api_urls[$key];
61 | }
62 |
63 | // 发起API请求
64 | private function request( $url, $method, $body ) {
65 |
66 | if(strpos($url,'msg_sec_check') !=false)
67 | {
68 | //内容安全检测不进行unicode转码
69 | $body =json_encode( $body,JSON_UNESCAPED_UNICODE);
70 |
71 | }
72 | else
73 | {
74 | $body =json_encode( $body );
75 |
76 | }
77 | $response = wp_remote_request( $url, array(
78 | 'method' => $method,
79 | 'body' =>$body
80 | ) );
81 |
82 | return ! is_wp_error( $response ) ? json_decode( $response['body'], true ) : false;
83 | }
84 |
85 | // 获取所有模板列表或帐号下模板列表
86 | public function get_templates( $type = 'my', $args = array() ) {
87 |
88 | $key = '';
89 | switch( $type ) {
90 | case 'all':
91 | $key = 'all_template';
92 | break;
93 | case 'my':
94 | $key = 'my_template';
95 | break;
96 | default:
97 | return false;
98 | }
99 |
100 | $api_url = $this->API($key);
101 | $body = RAW_Util::param_atts( array(
102 | 'offset' => 0,
103 | 'count' => 10
104 | ), $args );
105 |
106 | $result = $this->request( $api_url, 'POST', $body );
107 | return $result ? $result['list'] : false;
108 | }
109 |
110 | // 获取模板库某个模板标题下关键词库
111 | public function get_template_keywords( $id ) {
112 |
113 | $api_url = $this->API('get_template_keywords');
114 |
115 | $result = $this->request( $api_url, 'POST', array( 'id' => $id ) );
116 | return $result ? $result['keyword_list'] : false;
117 | }
118 |
119 | // 组合模板并添加至帐号下的个人模板库
120 | public function add_template( $args ) {
121 |
122 | $api_url = $this->API('add_template');
123 |
124 | $result = $this->request( $api_url, 'POST', $args );
125 | return $result ? $result['template_id'] : false;
126 | }
127 |
128 | // 删除帐号下的某个模板
129 | public function delete_template( $template_id ) {
130 |
131 | $api_url = $this->API('delete_template');
132 |
133 | $result = $this->request( $api_url, 'POST', array( 'template_id' => $template_id ) );
134 | return $result ? true : false;
135 | }
136 | //获取小程序二维码
137 | public function get_qrcode($data)
138 | {
139 | return $this->invokingRequest('get_qrcode',$data);
140 | }
141 |
142 | //获取直播房间信息
143 | public function getliveinfo($data)
144 | {
145 | return $this->invokingRequest('getliveinfo',$data);
146 | }
147 |
148 |
149 | //内容审查
150 | public function msgSecCheck($data)
151 | {
152 | return $this->invokingRequest('msgSecCheck',$data);
153 | }
154 |
155 | //获取小程序合作微信小店列表
156 | public function get_cooperation_shop_list($data)
157 | {
158 | $result = $this->invokingRequest('get_miniprogram_cooperation_shop_list',$data);
159 | return $result;
160 | }
161 |
162 | //获取微信调用开发者服务器所使用的出口IP
163 | public function get_callbackip($data)
164 | {
165 | return $this->invokingRequest('get_callbackip',$data);
166 |
167 | }
168 | public function invokingRequest($api,$data,$method='POST')
169 |
170 | {
171 | $access_token = $this->get_access_token();
172 | $access_token= $access_token?'?access_token=' . $access_token:'';
173 | $api_url = $this->API($api);
174 | $result ="";
175 | if(!empty($access_token))
176 | {
177 | $api_url=$api_url.$access_token;
178 |
179 | if ($api == "get_qrcode") {
180 |
181 | $data = json_encode($data);
182 | $result =get_content_post($api_url, $data); //小程序二维码
183 |
184 | } else {
185 | $result = $this->request($api_url, $method, $data);
186 | }
187 |
188 | }
189 | return $result ;
190 | }
191 |
192 | // 发送模板消息
193 | public function send_template($appid,$secret,$touser, $template_id, $page, $form_id, $data, $emphasis_keyword ) {
194 | $access_token = $this->get_access_token();
195 | $access_token= $access_token?'?access_token=' . $access_token:'';
196 | $api_url = $this->API('send_template');
197 | $error="0";
198 | $message="ok";
199 | if(!empty($access_token))
200 | {
201 | $api_url=$api_url.$access_token;
202 | $result = $this->request( $api_url, 'POST', array(
203 | 'touser' => $touser,
204 | 'template_id' => $template_id,
205 | 'page' => $page,
206 | 'form_id' => $form_id,
207 | 'data' => $data,
208 | 'emphasis_keyword' => $emphasis_keyword,
209 | ) );
210 | $error =$result['errcode'];
211 | if($error=='41029')
212 | {
213 |
214 | $message ='formid已被使用';
215 | }
216 |
217 | if($error=='40037')
218 | {
219 | $message ='templateid不正确';
220 | }
221 | if($error=='41028')
222 | {
223 | $message ='formid不正确,或者过期';
224 |
225 | }
226 | if($error=='41030')
227 | {
228 | $message ='page不正确';
229 |
230 | }
231 | if($error=='45009')
232 | {
233 | $message ='接口调用超过限额';
234 |
235 | }
236 |
237 | if($error=='0')
238 | {
239 | $message ='发送成功';
240 |
241 | }
242 |
243 | }
244 | else
245 | {
246 | $error ='01';
247 | $message ='获取access_token失败';
248 |
249 |
250 | }
251 |
252 | $result = array(
253 | 'error' => $error,
254 | 'message' =>$message
255 | );
256 |
257 | return $result;
258 |
259 |
260 | }
261 | }
262 |
263 |
--------------------------------------------------------------------------------
/includes/settings/wp-post-config.php:
--------------------------------------------------------------------------------
1 |
37 |
38 |
39 |
40 |
41 |
8 |
11 | getMessage();
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/includes/wxpay/WxPay.JsApiPay.php:
--------------------------------------------------------------------------------
1 | __CreateOauthUrlForCode($baseUrl);
49 | Header("Location: $url");
50 | exit();
51 | } else {
52 | //获取code码,以获取openid
53 | $code = $_GET['code'];
54 | $openid = $this->getOpenidFromMp($code);
55 | return $openid;
56 | }
57 | }
58 |
59 | /**
60 | *
61 | * 获取jsapi支付的参数
62 | * @param array $UnifiedOrderResult 统一支付接口返回的数据
63 | * @throws RAM_WxPayException
64 | *
65 | * @return json数据,可直接填入js函数作为参数
66 | */
67 | public function GetJsApiParameters($UnifiedOrderResult)
68 | {
69 | if(!array_key_exists("appid", $UnifiedOrderResult)
70 | || !array_key_exists("prepay_id", $UnifiedOrderResult)
71 | || $UnifiedOrderResult['prepay_id'] == "")
72 | {
73 | throw new RAM_WxPayException("参数错误");
74 | }
75 | $jsapi = new RAM_WxPayJsApiPay();
76 | $jsapi->SetAppid($UnifiedOrderResult["appid"]);
77 | $timeStamp = time();
78 | $jsapi->SetTimeStamp("$timeStamp");
79 | $jsapi->SetNonceStr(RAM_WxPayApi::getNonceStr());
80 | $jsapi->SetPackage("prepay_id=" . $UnifiedOrderResult['prepay_id']);
81 | $jsapi->SetSignType("MD5");
82 | $jsapi->SetPaySign($jsapi->MakeSign());
83 | //$parameters = json_encode($jsapi->GetValues());
84 | $parameters = $jsapi->GetValues(); //xjb 修改为返回数组
85 | return $parameters;
86 | }
87 |
88 | /**
89 | *
90 | * 通过code从工作平台获取openid机器access_token
91 | * @param string $code 微信跳转回来带上的code
92 | *
93 | * @return openid
94 | */
95 | public function GetOpenidFromMp($code)
96 | {
97 | $url = $this->__CreateOauthUrlForOpenid($code);
98 | //初始化curl
99 | $ch = curl_init();
100 | $curlVersion = curl_version();
101 | $ua = "WXPaySDK/0.0.5 (".PHP_OS.") PHP/".PHP_VERSION." CURL/".$curlVersion['version']." ".RAM_WxPayConfig::MCHID;
102 |
103 | //设置超时
104 | curl_setopt($ch, CURLOPT_TIMEOUT, $this->curl_timeout);
105 | curl_setopt($ch, CURLOPT_URL, $url);
106 | curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,FALSE);
107 | curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,FALSE);
108 | curl_setopt($ch,CURLOPT_USERAGENT, $ua);
109 | curl_setopt($ch, CURLOPT_HEADER, FALSE);
110 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
111 | if(RAM_WxPayConfig::CURL_PROXY_HOST != "0.0.0.0"
112 | && RAM_WxPayConfig::CURL_PROXY_PORT != 0){
113 | curl_setopt($ch,CURLOPT_PROXY, RAM_WxPayConfig::CURL_PROXY_HOST);
114 | curl_setopt($ch,CURLOPT_PROXYPORT, RAM_WxPayConfig::CURL_PROXY_PORT);
115 | }
116 | //运行curl,结果以jason形式返回
117 | $res = curl_exec($ch);
118 | curl_close($ch);
119 | //取出openid
120 | $data = json_decode($res,true);
121 | $this->data = $data;
122 | $openid = $data['openid'];
123 | return $openid;
124 | }
125 |
126 | /**
127 | *
128 | * 拼接签名字符串
129 | * @param array $urlObj
130 | *
131 | * @return 返回已经拼接好的字符串
132 | */
133 | private function ToUrlParams($urlObj)
134 | {
135 | $buff = "";
136 | foreach ($urlObj as $k => $v)
137 | {
138 | if($k != "sign"){
139 | $buff .= $k . "=" . $v . "&";
140 | }
141 | }
142 |
143 | $buff = trim($buff, "&");
144 | return $buff;
145 | }
146 |
147 | /**
148 | *
149 | * 获取地址js参数
150 | *
151 | * @return 获取共享收货地址js函数需要的参数,json格式可以直接做参数使用
152 | */
153 | public function GetEditAddressParameters()
154 | {
155 | $getData = $this->data;
156 | $data = array();
157 | $data["appid"] = RAM_WxPayConfig::APPID;
158 | $data["url"] = "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
159 | $time = time();
160 | $data["timestamp"] = "$time";
161 | $data["noncestr"] = "1234568";
162 | $data["accesstoken"] = $getData["access_token"];
163 | ksort($data);
164 | $params = $this->ToUrlParams($data);
165 | $addrSign = sha1($params);
166 |
167 | $afterData = array(
168 | "addrSign" => $addrSign,
169 | "signType" => "sha1",
170 | "scope" => "jsapi_address",
171 | "appId" => RAM_WxPayConfig::APPID,
172 | "timeStamp" => $data["timestamp"],
173 | "nonceStr" => $data["noncestr"]
174 | );
175 | $parameters = json_encode($afterData);
176 | return $parameters;
177 | }
178 |
179 | /**
180 | *
181 | * 构造获取code的url连接
182 | * @param string $redirectUrl 微信服务器回跳的url,需要url编码
183 | *
184 | * @return 返回构造好的url
185 | */
186 | private function __CreateOauthUrlForCode($redirectUrl)
187 | {
188 | $urlObj["appid"] = RAM_WxPayConfig::APPID;
189 | $urlObj["redirect_uri"] = "$redirectUrl";
190 | $urlObj["response_type"] = "code";
191 | $urlObj["scope"] = "snsapi_base";
192 | $urlObj["state"] = "STATE"."#wechat_redirect";
193 | $bizString = $this->ToUrlParams($urlObj);
194 | return "https://open.weixin.qq.com/connect/oauth2/authorize?".$bizString;
195 | }
196 |
197 | /**
198 | *
199 | * 构造获取open和access_toke的url地址
200 | * @param string $code,微信跳转带回的code
201 | *
202 | * @return 请求的url
203 | */
204 | private function __CreateOauthUrlForOpenid($code)
205 | {
206 | $urlObj["appid"] = RAM_WxPayConfig::APPID;
207 | $urlObj["secret"] = RAM_WxPayConfig::APPSECRET;
208 | $urlObj["code"] = $code;
209 | $urlObj["grant_type"] = "authorization_code";
210 | $bizString = $this->ToUrlParams($urlObj);
211 | return "https://api.weixin.qq.com/sns/oauth2/access_token?".$bizString;
212 | }
213 | }
214 |
--------------------------------------------------------------------------------
/includes/wxpay/WxPay.Notify.php:
--------------------------------------------------------------------------------
1 | SetReturn_code("FAIL");
22 | $this->SetReturn_msg($msg);
23 | $this->ReplyNotify(false);
24 | return;
25 | } else {
26 | //该分支在成功回调到NotifyCallBack方法,处理完成之后流程
27 | $this->SetReturn_code("SUCCESS");
28 | $this->SetReturn_msg("OK");
29 | }
30 | $this->ReplyNotify($needSign);
31 | }
32 |
33 | /**
34 | *
35 | * 回调方法入口,子类可重写该方法
36 | * 注意:
37 | * 1、微信回调超时时间为2s,建议用户使用异步处理流程,确认成功之后立刻回复微信服务器
38 | * 2、微信服务器在调用失败或者接到回包为非确认包的时候,会发起重试,需确保你的回调是可以重入
39 | * @param array $data 回调解释出的参数
40 | * @param string $msg 如果回调处理失败,可以将错误信息输出到该方法
41 | * @return true回调出来完成不需要继续回调,false回调处理未完成需要继续回调
42 | */
43 | public function NotifyProcess($data, &$msg)
44 | {
45 | //TODO 用户基础该类之后需要重写该方法,成功的时候返回true,失败返回false
46 | return true;
47 | }
48 |
49 | /**
50 | *
51 | * notify回调方法,该方法中需要赋值需要输出的参数,不可重写
52 | * @param array $data
53 | * @return true回调出来完成不需要继续回调,false回调处理未完成需要继续回调
54 | */
55 | final public function NotifyCallBack($data)
56 | {
57 | $msg = "OK";
58 | $result = $this->NotifyProcess($data, $msg);
59 |
60 | if($result == true){
61 | $this->SetReturn_code("SUCCESS");
62 | $this->SetReturn_msg("OK");
63 | } else {
64 | $this->SetReturn_code("FAIL");
65 | $this->SetReturn_msg($msg);
66 | }
67 | return $result;
68 | }
69 |
70 | /**
71 | *
72 | * 回复通知
73 | * @param bool $needSign 是否需要签名输出
74 | */
75 | final private function ReplyNotify($needSign = true)
76 | {
77 | //如果需要签名
78 | if($needSign == true &&
79 | $this->GetReturn_code($return_code) == "SUCCESS")
80 | {
81 | $this->SetSign();
82 | }
83 | WxpayApi::replyNotify($this->ToXml());
84 | }
85 | }
--------------------------------------------------------------------------------
/qrcode/index.php:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iamxjb/rest-api-to-miniprogram/c6c74b19237dbe8a2c815b4f78d5e829ac2485aa/qrcode/index.php
--------------------------------------------------------------------------------