PluginProbe
QuadMenu – Mega Menu / 3.3.8
QuadMenu – Mega Menu v3.3.8
3.3.8 3.3.7 3.3.6 trunk 1.8.4 1.8.5 1.8.7 1.8.8 1.8.9 1.9.0 1.9.2 1.9.3 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 All 88 releases
quadmenu / redux / ReduxCore / inc / fields / gallery / field_gallery.php

field_gallery.php in QuadMenu – Mega Menu 3.3.8, at redux/ReduxCore/inc/fields/gallery/field_gallery.php

106 lines 3.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Redux Framework is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 2 of the License, or
7 * any later version.
8 * Redux Framework is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with Redux Framework. If not, see <http://www.gnu.org/licenses/>.
14 *
15 * @package ReduxFrameworkLegacy
16 * @subpackage Field_Gallery
17 * @author Abdullah Almesbahi (cadr-sa)
18 * @version 3.0.0
19 */
20
21 // Exit if accessed directly
22 if ( ! defined( 'ABSPATH' ) ) {
23 exit;
24 }
25
26 // Don't duplicate me!
27 if ( ! class_exists( 'ReduxFrameworkLegacy_gallery' ) ) {
28
29 /**
30 * Main ReduxFrameworkLegacy_gallery class
31 *
32 * @since 3.0.0
33 */
34 class ReduxFrameworkLegacy_gallery {
35
36 /**
37 * Field Constructor.
38 * Required - must call the parent constructor, then assign field and value to vars, and obviously call the render field function
39 *
40 * @since 1.0.0
41 * @access public
42 * @return void
43 */
44 function __construct( $field = array(), $value = '', $parent = null ) {
45 $this->parent = $parent;
46 $this->field = $field;
47 $this->value = $value;
48 }
49
50 /**
51 * Field Render Function.
52 * Takes the vars and outputs the HTML for the field in the settings
53 *
54 * @since 1.0.0
55 * @access public
56 * @return void
57 */
58 public function render() {
59 echo '<div class="screenshot">';
60
61 if ( ! empty( $this->value ) ) {
62 $ids = explode( ',', $this->value );
63
64 foreach ( $ids as $attachment_id ) {
65 $img = wp_get_attachment_image_src( $attachment_id, 'thumbnail' );
66 echo '<a class="of-uploaded-image" href="' . $img[0] . '">';
67 echo '<img class="redux-option-image" id="image_' . $this->field['id'] . '_' . $attachment_id . '" src="' . $img[0] . '" alt="" target="_blank" rel="external" />';
68 echo '</a>';
69 }
70 }
71
72 echo '</div>';
73 echo '<a href="#" onclick="return false;" id="edit-gallery" class="gallery-attachments button button-primary">' . __( 'Add/Edit Gallery', 'redux-framework' ) . '</a> ';
74 echo '<a href="#" onclick="return false;" id="clear-gallery" class="gallery-attachments button">' . __( 'Clear Gallery', 'redux-framework' ) . '</a>';
75 echo '<input type="hidden" class="gallery_values ' . $this->field['class'] . '" value="' . esc_attr( $this->value ) . '" name="' . $this->field['name'] . $this->field['name_suffix'] . '" />';
76 }
77
78 /**
79 * Enqueue Function.
80 * If this field requires any scripts, or css define this function and register/enqueue the scripts/css
81 *
82 * @since 1.0.0
83 * @access public
84 * @return void
85 */
86 public function enqueue() {
87
88 if ( function_exists( 'wp_enqueue_media' ) ) {
89 wp_enqueue_media();
90 } else {
91 wp_enqueue_script( 'media-upload' );
92 wp_enqueue_script( 'thickbox' );
93 wp_enqueue_style( 'thickbox' );
94 }
95
96 wp_enqueue_script(
97 'redux-field-gallery-js',
98 ReduxFrameworkLegacy::$_url . 'inc/fields/gallery/field_gallery' . ReduxLegacy_Functions::isMin() . '.js',
99 array( 'jquery', 'redux-js' ),
100 time(),
101 true
102 );
103 }
104 }
105 }
106