Plugin Directory

Changeset 3619020


Ignore:
Timestamp:
07/22/2026 05:27:06 PM (3 months ago)
Author:
freelancermartin
Message:

1.4.0: Remove Redux Framework dependency, fix image/settings bugs

Location:
spartan-gallery
Files:
12 added
6 deleted
46 edited
1 copied

Legend:

Unmodified
Added
Removed
  • spartan-gallery/tags/1.4.0/admin/class-add-gallery-gutenberg-block.php

    r3204032 r3619020  
    11<?php
     2
     3if ( ! defined( 'WPINC' ) ) {
     4        die;
     5}
    26
    37// Register the block and its settings
    … …  
    4549                        $my_meta_options = get_post_meta( $gallery_id , 'image_layout_select', true ); // array
    4650
    47                         $get_all_post_attachements = get_post_meta( $gallery_id , 'spartan_gallery_uploaded_images', true );
    48            
    49                        
     51                        $get_all_post_attachements = get_post_meta( $gallery_id , 'spartan_gallery_uploaded_images', true );
    5052
    5153                        // Loop through each post ID
    52                         foreach (explode(',',$get_all_post_attachements) as $post_id) {
    53                                 // Retrieve the post object by ID
    54                                 $post = get_post($post_id);
     54                        $post_guids = array();
     55                        if ( ! empty( $get_all_post_attachements ) ) {
     56                                foreach ( explode( ',', $get_all_post_attachements ) as $post_id ) {
     57                                        // Retrieve the post object by ID
     58                                        $post = get_post( absint( $post_id ) );
    5559
    56                                 // Check if the post exists
    57                                 if ($post) {
    58                                         // Get the GUID of the post and push it into the array
    59                                         $post_guids[] = $post;
     60                                        // Check if the post exists
     61                                        if ( $post ) {
     62                                                // Get the GUID of the post and push it into the array
     63                                                $post_guids[] = $post;
     64                                        }
    6065                                }
     66                        }
     67
     68                        if ( empty( $post_guids ) ) {
     69                                return '<p>No images found in this gallery.</p>';
    6170                        }
    6271
  • spartan-gallery/tags/1.4.0/admin/class-spartan-gallery-admin.php

    r3204032 r3619020  
    6060                $this->plugin_name = $plugin_name;
    6161                $this->version = $version;
    62                 // Hook into plugin activation
    63                 add_action( 'admin_init', array($this,'spartan_gallery_check_and_install_redux' ));
    64 
    65                 add_action( 'plugins_loaded', array($this,'spartan_gallery_load_redux' ));
    66                
    6762
    6863        }
    … …  
    121116
    122117
    123         public function spartan_gallery_check_and_install_redux()
    124         {
    125                 // Ensure WordPress is loaded
    126                 if ( ! function_exists( 'wp_generate_password' ) ) {
    127                         error_log( 'WordPress not fully loaded. Aborting Redux installation.' );
    128                         return;
    129                 }
    130        
    131                 if ( ! class_exists( 'ReduxFramework' ) ) {
    132                         require_once ABSPATH . 'wp-admin/includes/plugin-install.php';
    133                         require_once ABSPATH . 'wp-admin/includes/file.php';
    134                         require_once ABSPATH . 'wp-admin/includes/misc.php';
    135                         require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
    136        
    137                         // Get plugin information for Redux Framework
    138                         $plugin_slug = 'redux-framework';
    139                         $plugin_info = plugins_api( 'plugin_information', array( 'slug' => $plugin_slug ) );
    140        
    141                         if ( is_wp_error( $plugin_info ) ) {
    142                                 error_log( 'Error fetching Redux Framework plugin info: ' . $plugin_info->get_error_message() );
    143                                 return;
    144                         }
    145        
    146                         $download_link = $plugin_info->download_link;
    147        
    148                         $upgrader = new Plugin_Upgrader();
    149                         $installed = $upgrader->install( $download_link );
    150        
    151                         if ( $installed ) {
    152                                 $plugin_file = WP_PLUGIN_DIR . "/$plugin_slug/$plugin_slug.php";
    153                                 if ( file_exists( $plugin_file ) ) {
    154                                         activate_plugin( $plugin_file );
    155                                 } else {
    156                                         error_log( 'Redux Framework installation failed: Plugin file not found.' );
    157                                 }
    158                         } else {
    159                                 error_log( 'Redux Framework installation failed: Unable to download or install the plugin.' );
    160                         }
    161                 }
    162         }
    163 
    164         // Load Redux Framework after all plugins are loaded
    165         public function spartan_gallery_load_redux() {
    166                 // Check if Redux Framework is installed and active
    167                 if ( class_exists( 'ReduxFramework' ) )
    168                 {
    169                        
    170                         // Path to Redux plugin's main file
    171                         $redux_plugin_file = WP_PLUGIN_DIR . '/redux-framework/redux-framework.php';
    172                        
    173                         if ( file_exists( $redux_plugin_file ) ) {
    174                                 include_once $redux_plugin_file;
    175        
    176                                 // Now include your Redux configuration file
    177                                 //require_once plugin_dir_path( __FILE__ ) . 'redux-config.php';
    178                                 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-spartan-gallery-options.php';
    179                         } else {
    180                                 error_log( 'Redux Framework plugin is not installed or not found in the plugins directory.' );
    181                         }
    182                 }
    183         }
    184        
    185        
    186        
    187 
    188118}
  • spartan-gallery/tags/1.4.0/admin/class-spartan-gallery-metaboxes.php

    r2145680 r3619020  
    77*/
    88if ( ! defined( 'WPINC' ) ) {
    9 
    109    die;
    11 
    1210}
    13 
    1411
    1512function spartan_gallery_meta_box_add()
    … …  
    1714    add_meta_box( 'new-spartan-gallery-box', 'Shortcode', 'spartan_gallery_paybal_meta_box_cb', 'spartan_gallery_type', 'normal', 'low' );
    1815}
    19 
    2016add_action( 'add_meta_boxes', 'spartan_gallery_meta_box_add' );
    2117
    2218function spartan_gallery_paybal_meta_box_cb()
    2319{
    24 
     20    $gallery_id = absint( get_the_ID() );
    2521?>
    2622
    27 
    28   <div >
    29 
    30 
     23  <div>
    3124      <div class="postbox">
    32 
    33           <h3 style="border-bottom: 1px solid #EEE;background: #f7f7f7;"><span class="tcode"><?php _e("Shortcode", "easy-textillate"); ?></span></h3>
     25          <h3 style="border-bottom: 1px solid #EEE;background: #f7f7f7;"><span class="tcode"><?php esc_html_e( 'Shortcode', 'spartan-gallery' ); ?></span></h3>
    3426          <div class="inside" style="padding-bottom:20px;display: block;">
    35 
    36           <table width="100%">
    37           <tr><td>
    38 
    39            <p><code style="color:#A71D5D;" >[spartan_gallery  id='<?php print_r(get_the_ID()); ?>']</code></p>
    40 
    41           </td>
    42           <td width="50px" style="align:right;">
    43 
    44            </td></tr>
    45            </table>
    46 
     27              <table width="100%">
     28              <tr><td>
     29                  <p><code style="color:#A71D5D;">[spartan_gallery id='<?php echo esc_html( $gallery_id ); ?>']</code></p>
     30              </td></tr>
     31              </table>
    4732          </div>
    4833      </div>
    4934
    5035      <div class="postbox">
    51           <h3 style="border-bottom: 1px solid #EEE;background: #f7f7f7;"><span class="tcode"><?php _e("PHP code", "easy-textillate"); ?></span></h3>
     36          <h3 style="border-bottom: 1px solid #EEE;background: #f7f7f7;"><span class="tcode"><?php esc_html_e( 'PHP code', 'spartan-gallery' ); ?></span></h3>
    5237          <div class="inside" style="padding-bottom:20px;display: block;">
    53 
    54           <table width="100%">
    55           <tr><td>
    56             <p><code style="color:#A71D5D;" >echo do_shortcode("[spartan_gallery id='<?php print_r(get_the_ID()); ?>']");</code></p>
    57            </td>
    58           <td width="50px" style="align:right;">
    59 
    60 
    61 
    62            </td></tr>
    63            </table>
    64 
     38              <table width="100%">
     39              <tr><td>
     40                  <p><code style="color:#A71D5D;">echo do_shortcode("[spartan_gallery id='<?php echo esc_html( $gallery_id ); ?>']");</code></p>
     41              </td></tr>
     42              </table>
    6543          </div>
    6644      </div>
    6745
    6846      <div class="postbox">
    69           <h3 style="border-bottom: 1px solid #EEE;background: #f7f7f7;"><span class="tcode"><?php _e("Do you like this plugin ?", "easy-textillate"); ?></span></h3>
     47          <h3 style="border-bottom: 1px solid #EEE;background: #f7f7f7;"><span class="tcode"><?php esc_html_e( 'Do you like this plugin?', 'spartan-gallery' ); ?></span></h3>
    7048          <div class="inside" style="display: block;">
    71               <img src="<?php echo plugin_dir_url( '' ) . 'spartan-gallery/admin/img/index.jpeg'; ?>" title="<?php _e("buy me a coffee", "easy-textillate"); ?>" style=" margin: 5px; float:left;" />
    72 
    73               <p><?php _e("Hi! I'm <strong>Freelancer Martin</strong>, developer of this plugin.", "easy-textillate"); ?></p>
    74               <p><?php _e("I've been spending many hours to develop this plugin.", "easy-textillate"); ?> <br />
    75               <?php _e("If you like and use this plugin and would like to see future development, you can <strong>buy me a cup of coffee</strong>.", "easy-textillate"); ?></p>
     49              <img src="<?php echo esc_url( plugin_dir_url( '' ) . 'spartan-gallery/admin/img/index.jpeg' ); ?>" title="<?php esc_attr_e( 'buy me a coffee', 'spartan-gallery' ); ?>" style="margin: 5px; float:left;" />
     50              <p><?php esc_html_e( "Hi! I'm Freelancer Martin, developer of this plugin.", 'spartan-gallery' ); ?></p>
     51              <p><?php esc_html_e( "I've been spending many hours to develop this plugin.", 'spartan-gallery' ); ?><br />
     52              <?php esc_html_e( 'If you like and use this plugin and would like to see future development, you can buy me a cup of coffee.', 'spartan-gallery' ); ?></p>
    7653              <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=CVJ7GE7QM5F3N" target="_blank" rel="nofollow"><img src="https://www.paypal.com/en_US/i/btn/x-click-but21.gif" alt="" /></a>
    77 
    78 
    7954              <div style="clear:both;"></div>
    80        </div>
    81 
     55          </div>
     56      </div>
    8257  </div>
    8358
    84 
    8559<?php
    86 
    8760}
  • spartan-gallery/tags/1.4.0/admin/class-spartan-gallery-options.php

    r3204032 r3619020  
    11<?php
    2 if ( ! class_exists( 'Redux' ) ) {
    3     return;
     2/**
     3 * Spartan Gallery Options metabox.
     4 *
     5 * Native WordPress replacement for the previous Redux Framework options panel.
     6 * Renders the same sections/fields and writes to the exact same post_meta keys
     7 * the rest of the plugin (public/html-cointainer-outputs/*, spartan-gallery-styles.php)
     8 * already reads, so no other file needed to change.
     9 *
     10 * @package Spartan_Gallery
     11 * @subpackage Spartan_Gallery/admin
     12 */
     13if ( ! defined( 'WPINC' ) ) {
     14        die;
    415}
    516
    6 $opt_name = 'spartan_gallery_options';
    7 /*
    8 $args = array(
    9     'opt_name'             => $opt_name,
    10     'display_name'         => 'My Plugin Options',
    11     'menu_title'           => 'My Plugin Settings',
    12     'page_title'           => 'My Plugin Options',
    13     'admin_bar'            => true,
    14     'menu_type'            => 'menu',
    15     'allow_sub_menu'       => true,
    16     'page_parent_post_type' => 'spartan_gallery_type',
    17     'customizer'           => true,
    18 );
    19 */
    20 Redux::setArgs( $opt_name/*, $args*/ );
    21 
    22 
    23 
    24 // Example Section
    25 Redux::setSection( $opt_name, array(
    26     'title'  => 'General Settings',
    27     //'id'     => 'general',
    28     'desc'   => 'Basic settings for your plugin.',
    29    
    30 ) );
    31 
    32 // Change this variable to the opt_name of YOUR project.
    33 //$opt_name = 'your_opt_name';
    34 /*
    35 // Standard metabox.
    36 Redux_Metaboxes::set_box(
    37         $opt_name,
    38         array(
    39                 'id'         => 'opt-metaboxes',
    40                 'title'      => esc_html__( 'Metabox Options', 'your-textdomain-here' ),
    41                 'post_types' => array( 'spartan_gallery_type' ),
    42                 'position'   => 'normal', // normal, advanced, side.
    43                 'priority'   => 'high',   // high, core, default, low.
    44                 'sections'   => array(
     17class Spartan_Gallery_Options {
     18
     19        const POST_TYPE = 'spartan_gallery_type';
     20        const NONCE_ACTION = 'spartan_gallery_options_save';
     21        const NONCE_NAME   = 'spartan_gallery_options_nonce';
     22
     23        public static function init() {
     24                add_action( 'add_meta_boxes', array( __CLASS__, 'add_meta_box' ) );
     25                add_action( 'save_post', array( __CLASS__, 'save' ) );
     26                add_action( 'admin_enqueue_scripts', array( __CLASS__, 'enqueue_assets' ) );
     27        }
     28
     29        public static function add_meta_box() {
     30                add_meta_box(
     31                        'spartan-gallery-options',
     32                        esc_html__( 'Spartan Gallery Options', 'spartan-gallery' ),
     33                        array( __CLASS__, 'render' ),
     34                        self::POST_TYPE,
     35                        'normal',
     36                        'high'
     37                );
     38        }
     39
     40        public static function enqueue_assets( $hook ) {
     41                if ( ! in_array( $hook, array( 'post.php', 'post-new.php' ), true ) ) {
     42                        return;
     43                }
     44
     45                $screen = get_current_screen();
     46                if ( ! $screen || self::POST_TYPE !== $screen->post_type ) {
     47                        return;
     48                }
     49
     50                wp_enqueue_style( 'wp-color-picker' );
     51                wp_enqueue_style(
     52                        'spartan-gallery-options',
     53                        plugin_dir_url( __FILE__ ) . 'css/spartan-gallery-options.css',
     54                        array( 'wp-color-picker' ),
     55                        PLUGIN_NAME_VERSION
     56                );
     57
     58                wp_enqueue_media();
     59                wp_enqueue_script( 'jquery-ui-slider' );
     60                wp_enqueue_script( 'jquery-ui-spinner' );
     61                wp_enqueue_script( 'wp-color-picker' );
     62
     63                $cm_settings = wp_enqueue_code_editor( array( 'type' => 'text/css' ) );
     64
     65                wp_enqueue_script(
     66                        'spartan-gallery-options',
     67                        plugin_dir_url( __FILE__ ) . 'js/spartan-gallery-options.js',
     68                        array( 'jquery', 'jquery-ui-slider', 'jquery-ui-spinner', 'wp-color-picker', 'media-editor' ),
     69                        PLUGIN_NAME_VERSION,
     70                        true
     71                );
     72
     73                wp_localize_script(
     74                        'spartan-gallery-options',
     75                        'sgOptionsData',
    4576                        array(
    46                                 'title'  => esc_html__( 'Basic Field', 'your-textdomain-here' ),
    47                                 'id'     => 'opt-basic-fields',
    48                                 'desc'   => esc_html__( 'Redux Framework was created with the developer in mind. It allows for any theme developer to have an advanced theme panel with most of the features a developer would need. For more information check out the Github repo at:', 'your-textdomain-here' ) . '  <a href="https://github.com/ReduxFramework/Redux-Framework">https://github.com/ReduxFramework/Redux-Framework</a>',
    49                                 'icon'   => 'el-icon-cogs',
    50                                 'fields' => array(
    51                                         array(
    52                                                 'id'       => 'opt-checkbox',
    53                                                 'type'     => 'checkbox',
    54                                                 'title'    => esc_html__( 'Checkbox', 'your-textdomain-here' ),
    55                                                 'subtitle' => esc_html__( 'Basic Checkbox field.', 'your-textdomain-here' ),
    56                                                 'default'  => true,
    57                                         ),
    58                                         array(
    59                                                 'id'       => 'switch-on',
    60                                                 'type'     => 'switch',
    61                                                 'title'    => esc_html__( 'Switch On', 'your-textdomain-here' ),
    62                                                 'subtitle' => esc_html__( 'Look, it\'s on!', 'your-textdomain-here' ),
    63                                                 'default'  => 1,
    64                                         ),
    65                                 ),
    66                         ),
     77                                'codeEditor' => $cm_settings,
     78                                'mediaTitle' => esc_html__( 'Select gallery images', 'spartan-gallery' ),
     79                                'mediaButton' => esc_html__( 'Use selected images', 'spartan-gallery' ),
     80                        )
     81                );
     82        }
     83
     84        private static function meta( $post_id, $key, $default = '' ) {
     85                // metadata_exists(), not an emptiness check: update_post_meta() legitimately
     86                // stores '' when a checkbox is unchecked, and that must NOT be treated the
     87                // same as "never saved, show the default" or unchecked switches could never
     88                // actually be turned off.
     89                if ( ! metadata_exists( 'post', $post_id, $key ) ) {
     90                        return $default;
     91                }
     92                return get_post_meta( $post_id, $key, true );
     93        }
     94
     95        private static function tabs() {
     96                return array(
     97                        'layout'    => array( esc_html__( 'Gallery Layout Options', 'spartan-gallery' ), 'dashicons-layout' ),
     98                        'upload'    => array( esc_html__( 'Upload Images', 'spartan-gallery' ), 'dashicons-format-gallery' ),
     99                        'image'     => array( esc_html__( 'Image Options', 'spartan-gallery' ), 'dashicons-admin-generic' ),
     100                        'container' => array( esc_html__( 'Gallery Container Settings', 'spartan-gallery' ), 'dashicons-admin-appearance' ),
     101                        'css'       => array( esc_html__( 'Insert Custom CSS', 'spartan-gallery' ), 'dashicons-editor-code' ),
     102                );
     103        }
     104
     105        private static function render_nav( $active ) {
     106                echo '<div class="sg-options-nav">';
     107                foreach ( self::tabs() as $id => $tab ) {
     108                        list( $label, $icon ) = $tab;
     109                        $class = 'sg-options-nav-item' . ( $id === $active ? ' active' : '' );
     110                        echo '<button type="button" class="' . esc_attr( $class ) . '" data-panel="' . esc_attr( $id ) . '">';
     111                        echo '<span class="dashicons ' . esc_attr( $icon ) . '"></span>';
     112                        echo '<span class="sg-nav-label">' . esc_html( $label ) . '</span>';
     113                        echo '</button>';
     114                }
     115                echo '</div>';
     116        }
     117
     118        private static function section_open( $id, $title, $desc = '' ) {
     119                $active = ( 'layout' === $id );
     120                echo '<div class="sg-options-panel' . ( $active ? ' active' : '' ) . '" data-panel="' . esc_attr( $id ) . '">';
     121                echo '<h3 class="sg-options-section-title">' . esc_html( $title ) . '</h3>';
     122                if ( $desc ) {
     123                        echo '<p class="sg-options-section-desc">' . wp_kses_post( $desc ) . '</p>';
     124                }
     125                echo '<table class="form-table sg-options-table"><tbody>';
     126        }
     127
     128        private static function section_close() {
     129                echo '</tbody></table></div>';
     130        }
     131
     132        private static function row_open( $label, $for = '' ) {
     133                echo '<tr><th scope="row">';
     134                if ( $for ) {
     135                        echo '<label for="' . esc_attr( $for ) . '">' . esc_html( $label ) . '</label>';
     136                } else {
     137                        echo esc_html( $label );
     138                }
     139                echo '</th><td>';
     140        }
     141
     142        private static function row_close( $desc = '' ) {
     143                if ( $desc ) {
     144                        echo '<p class="description">' . wp_kses_post( $desc ) . '</p>';
     145                }
     146                echo '</td></tr>';
     147        }
     148
     149        public static function render( $post ) {
     150                wp_nonce_field( self::NONCE_ACTION, self::NONCE_NAME );
     151
     152                $gallery_id = $post->ID;
     153
     154                echo '<div class="sg-options-wrap">';
     155                self::render_nav( 'layout' );
     156                echo '<div class="sg-options-content">';
     157
     158                // Section 1: Gallery Layout Options.
     159                self::section_open( 'layout', esc_html__( 'Gallery Layout Options', 'spartan-gallery' ) );
     160                $layout = self::meta( $gallery_id, 'image_layout_select', 'value-1' );
     161                $layouts = array(
     162                        'value-1' => array( esc_html__( 'Freewall Chaotic', 'spartan-gallery' ), 'FlexFreewallTable.png' ),
     163                        'value-2' => array( esc_html__( 'Random', 'spartan-gallery' ), 'ImageFreewallGrid.png' ),
     164                        'value-3' => array( esc_html__( 'Fixed', 'spartan-gallery' ), 'NestedFreewallGrid.png' ),
     165                        'value-4' => array( esc_html__( 'Pinterest', 'spartan-gallery' ), 'PinterestFreewallGrid.png' ),
     166                        'value-5' => array( esc_html__( 'Hexagon', 'spartan-gallery' ), 'hexagon_layout.jpg' ),
     167                        'value-6' => array( esc_html__( '3D Slider', 'spartan-gallery' ), 'spartan_3D_layout.png' ),
     168                );
     169                echo '<tr><td colspan="2">';
     170                echo '<p class="description">' . esc_html__( 'Gallery layout looks exactly like the preview image. To change the aspect ratio, select the third layout, turn "Display Adjustable Image" ON under Image Options, and turn "Display thumbnail size" OFF. Width/height only apply to the third and sixth layouts; other layouts size images randomly for the grid.', 'spartan-gallery' ) . '</p>';
     171                echo '<div class="sg-image-select">';
     172                foreach ( $layouts as $value => $data ) {
     173                        list( $label, $file ) = $data;
     174                        $img_url = plugins_url( 'img/' . $file, __FILE__ );
     175                        $checked = checked( $layout, $value, false );
     176                        echo '<label class="sg-image-select-option' . ( $layout === $value ? ' selected' : '' ) . '">';
     177                        echo '<input type="radio" name="image_layout_select" value="' . esc_attr( $value ) . '" ' . $checked . ' />';
     178                        echo '<img src="' . esc_url( $img_url ) . '" alt="' . esc_attr( $label ) . '" />';
     179                        echo '<span>' . esc_html( $label ) . '</span>';
     180                        echo '</label>';
     181                }
     182                echo '</div>';
     183                echo '</td></tr>';
     184                self::section_close();
     185
     186                // Section 2: Upload Images.
     187                self::section_open( 'upload', esc_html__( 'Upload Images', 'spartan-gallery' ) );
     188                $uploaded_ids = self::meta( $gallery_id, 'spartan_gallery_uploaded_images', '' );
     189                self::row_open( esc_html__( 'Upload', 'spartan-gallery' ) );
     190                echo '<input type="hidden" id="spartan_gallery_uploaded_images" name="spartan_gallery_uploaded_images" value="' . esc_attr( $uploaded_ids ) . '" />';
     191                echo '<div id="sg-gallery-preview" class="sg-gallery-preview">';
     192                if ( ! empty( $uploaded_ids ) ) {
     193                        foreach ( explode( ',', $uploaded_ids ) as $att_id ) {
     194                                $att_id = absint( $att_id );
     195                                if ( ! $att_id ) {
     196                                        continue;
     197                                }
     198                                $thumb = wp_get_attachment_image_src( $att_id, 'thumbnail' );
     199                                if ( $thumb ) {
     200                                        echo '<span class="sg-gallery-thumb" data-id="' . esc_attr( $att_id ) . '"><img src="' . esc_url( $thumb[0] ) . '" /><a href="#" class="sg-gallery-remove" title="' . esc_attr__( 'Remove', 'spartan-gallery' ) . '">&times;</a></span>';
     201                                }
     202                        }
     203                }
     204                echo '</div>';
     205                echo '<p><button type="button" class="button" id="sg-gallery-select">' . esc_html__( 'Select / Manage Images', 'spartan-gallery' ) . '</button></p>';
     206                self::row_close();
     207                self::section_close();
     208
     209                // Section 3: Image Options.
     210                self::section_open( 'image', esc_html__( 'Image Options', 'spartan-gallery' ) );
     211
     212                self::row_open( esc_html__( 'Display Adjustable Image', 'spartan-gallery' ), 'display_original' );
     213                $display_original = self::meta( $gallery_id, 'display_original', '' );
     214                echo '<label class="sg-switch"><input type="checkbox" id="display_original" name="display_original" value="1" ' . checked( $display_original, '1', false ) . ' /> ' . esc_html__( 'Enabled', 'spartan-gallery' ) . '</label>';
     215                self::row_close( esc_html__( '"Display thumbnail size" can\'t be turned on when this setting is turned on.', 'spartan-gallery' ) );
     216
     217                self::row_open( esc_html__( 'Image width (PX)', 'spartan-gallery' ), 'image_width' );
     218                $image_width = self::meta( $gallery_id, 'image_width', 150 );
     219                echo '<div class="sg-slider" id="image_width_slider" data-target="image_width" data-min="0" data-max="2000" data-step="1"></div>';
     220                echo '<input type="text" class="sg-slider-value" id="image_width" name="image_width" value="' . esc_attr( $image_width ) . '" readonly="readonly" />';
     221                self::row_close();
     222
     223                self::row_open( esc_html__( 'Image height (PX)', 'spartan-gallery' ), 'image_height' );
     224                $image_height = self::meta( $gallery_id, 'image_height', 150 );
     225                echo '<div class="sg-slider" id="image_height_slider" data-target="image_height" data-min="0" data-max="2000" data-step="1"></div>';
     226                echo '<input type="text" class="sg-slider-value" id="image_height" name="image_height" value="' . esc_attr( $image_height ) . '" readonly="readonly" />';
     227                self::row_close();
     228
     229                self::row_open( esc_html__( 'Img measure value', 'spartan-gallery' ), 'image_measure_value' );
     230                $measure = self::meta( $gallery_id, 'image_measure_value', 'px' );
     231                echo '<select id="image_measure_value" name="image_measure_value">';
     232                foreach ( array( 'px' => 'px', '%' => '%', 'vh' => 'vh/vw', 'rem' => 'rem' ) as $val => $label ) {
     233                        echo '<option value="' . esc_attr( $val ) . '" ' . selected( $measure, $val, false ) . '>' . esc_html( $label ) . '</option>';
     234                }
     235                echo '</select>';
     236                self::row_close();
     237
     238                self::row_open( esc_html__( 'Display thumbnail size', 'spartan-gallery' ), 'thumbnail_options' );
     239                $thumb_opt = self::meta( $gallery_id, 'thumbnail_options', '1' );
     240                echo '<label class="sg-switch"><input type="checkbox" id="thumbnail_options" name="thumbnail_options" value="1" ' . checked( $thumb_opt, '1', false ) . ' /> ' . esc_html__( 'Enabled', 'spartan-gallery' ) . '</label>';
     241                self::row_close( esc_html__( '"Display Adjustable Image" can\'t be turned on when this setting is turned on.', 'spartan-gallery' ) );
     242
     243                self::row_open( esc_html__( 'Select Thumbnail Size', 'spartan-gallery' ), 'thumbnail_size' );
     244                $thumb_size = self::meta( $gallery_id, 'thumbnail_size', 'medium_large' );
     245                $thumb_sizes = array(
     246                        'thumbnail'    => esc_html__( 'Thumbnail (default 150px x 150px max)', 'spartan-gallery' ),
     247                        'medium'       => esc_html__( 'Medium resolution (default 300px x 300px max)', 'spartan-gallery' ),
     248                        'medium_large' => esc_html__( 'Medium Large resolution (default 768px x 0px max)', 'spartan-gallery' ),
     249                        'large'        => esc_html__( 'Large resolution (default 1024px x 1024px max)', 'spartan-gallery' ),
     250                        'original'     => esc_html__( 'Original image resolution (unmodified)', 'spartan-gallery' ),
     251                );
     252                echo '<select id="thumbnail_size" name="thumbnail_size">';
     253                foreach ( $thumb_sizes as $val => $label ) {
     254                        echo '<option value="' . esc_attr( $val ) . '" ' . selected( $thumb_size, $val, false ) . '>' . esc_html( $label ) . '</option>';
     255                }
     256                echo '</select>';
     257                self::row_close();
     258
     259                self::row_open( esc_html__( 'Image Margin (PX)', 'spartan-gallery' ), 'img_margin' );
     260                $img_margin = self::meta( $gallery_id, 'img_margin', 20 );
     261                echo '<input type="text" class="sg-spinner" id="img_margin" name="img_margin" value="' . esc_attr( $img_margin ) . '" data-min="0" data-max="100" data-step="1" />';
     262                self::row_close();
     263
     264                self::section_close();
     265
     266                // Section 5: Gallery Container Settings.
     267                self::section_open( 'container', esc_html__( 'Gallery Container Settings', 'spartan-gallery' ) );
     268
     269                self::row_open( esc_html__( 'Turn settings On/Off', 'spartan-gallery' ), 'container_settings_on_off' );
     270                $container_on = self::meta( $gallery_id, 'container_settings_on_off', '' );
     271                echo '<label class="sg-switch"><input type="checkbox" id="container_settings_on_off" name="container_settings_on_off" value="1" ' . checked( $container_on, '1', false ) . ' /> ' . esc_html__( 'Enabled', 'spartan-gallery' ) . '</label>';
     272                self::row_close();
     273
     274                self::row_open( esc_html__( 'Container dimensions (Width/Height)', 'spartan-gallery' ) );
     275                $dims = self::meta( $gallery_id, 'container_height_width_range', array() );
     276                $dims = wp_parse_args(
     277                        is_array( $dims ) ? $dims : array(),
     278                        array( 'width' => '200px', 'height' => '' )
     279                );
     280                list( $w_num, $w_unit ) = self::split_length( $dims['width'], '200', 'px' );
     281                list( $h_num, $h_unit ) = self::split_length( $dims['height'], '', 'px' );
     282                echo '<div class="sg-dimensions">';
     283                echo '<span><label>' . esc_html__( 'Width', 'spartan-gallery' ) . '</label> <input type="text" name="container_width_num" value="' . esc_attr( $w_num ) . '" size="6" /> ';
     284                echo self::unit_select( 'container_width_unit', $w_unit );
     285                echo '</span> <span><label>' . esc_html__( 'Height', 'spartan-gallery' ) . '</label> <input type="text" name="container_height_num" value="' . esc_attr( $h_num ) . '" size="6" /> ';
     286                echo self::unit_select( 'container_height_unit', $h_unit );
     287                echo '</span>';
     288                echo '</div>';
     289                self::row_close();
     290
     291                self::row_open( esc_html__( 'Background Color', 'spartan-gallery' ), 'container_background_color' );
     292                $container_bg = self::meta( $gallery_id, 'container_background_color', '#FFFFFF' );
     293                echo '<input type="text" class="sg-color-field" id="container_background_color" name="container_background_color" value="' . esc_attr( $container_bg ) . '" data-default-color="#FFFFFF" />';
     294                self::row_close();
     295
     296                self::row_open( esc_html__( 'Border Option', 'spartan-gallery' ) );
     297                $border = self::meta( $gallery_id, 'container_border', array() );
     298                $border = wp_parse_args(
     299                        is_array( $border ) ? $border : array(),
    67300                        array(
    68                                 'title'      => esc_html__( 'Text Field', 'your-textdomain-here' ),
    69                                 'desc'       => esc_html__( 'Redux Framework was created with the developer in mind. It allows for any theme developer to have an advanced theme panel with most of the features a developer would need. For more information check out the Github repo at:', 'your-textdomain-here' ) . '  <a href="https://github.com/ReduxFramework/Redux-Framework">https://github.com/ReduxFramework/Redux-Framework</a>',
    70                                 'icon'       => 'el-icon-cog',
    71                                 'id'         => 'opt-text-fields',
    72                                 'subsection' => true,
    73                                 'fields'     => array(
    74                                         array(
    75                                                 'title' => esc_html__( 'Text Field', 'your-textdomain-here' ),
    76                                                 'id'    => 'opt-text',
    77                                                 'type'  => 'text',
    78                                         ),
    79                                 ),
    80                         ),
     301                                'border-color'  => '#000000',
     302                                'border-style'  => 'none',
     303                                'border-top'    => '',
     304                                'border-right'  => '',
     305                                'border-bottom' => '',
     306                                'border-left'   => '',
     307                        )
     308                );
     309                echo '<div class="sg-border">';
     310                echo '<span><label>' . esc_html__( 'Style', 'spartan-gallery' ) . '</label> <select name="container_border[border-style]">';
     311                foreach ( array( 'none', 'solid', 'dashed', 'dotted', 'double', 'groove', 'ridge', 'inset', 'outset' ) as $style ) {
     312                        echo '<option value="' . esc_attr( $style ) . '" ' . selected( $border['border-style'], $style, false ) . '>' . esc_html( $style ) . '</option>';
     313                }
     314                echo '</select></span> ';
     315                echo '<span><label>' . esc_html__( 'Color', 'spartan-gallery' ) . '</label> <input type="text" class="sg-color-field" name="container_border[border-color]" value="' . esc_attr( $border['border-color'] ) . '" data-default-color="#000000" /></span>';
     316                echo '<div class="sg-border-widths">';
     317                $border_sides = array(
     318                        'border-top'    => __( 'Top', 'spartan-gallery' ),
     319                        'border-right'  => __( 'Right', 'spartan-gallery' ),
     320                        'border-bottom' => __( 'Bottom', 'spartan-gallery' ),
     321                        'border-left'   => __( 'Left', 'spartan-gallery' ),
     322                );
     323                foreach ( $border_sides as $side => $side_label ) {
     324                        echo '<span><label>' . esc_html( $side_label ) . '</label> <input type="text" name="container_border[' . esc_attr( $side ) . ']" value="' . esc_attr( $border[ $side ] ) . '" size="6" placeholder="e.g. 1px" /></span>';
     325                }
     326                echo '</div>';
     327                echo '</div>';
     328                self::row_close( esc_html__( 'Only applies when "Turn settings On/Off" above is enabled.', 'spartan-gallery' ) );
     329
     330                self::section_close();
     331
     332                // Section 6: Insert Custom CSS.
     333                self::section_open( 'css', esc_html__( 'Insert Custom CSS', 'spartan-gallery' ) );
     334                self::row_open( esc_html__( 'CSS Code', 'spartan-gallery' ), 'add_extra_css' );
     335                $extra_css = self::meta( $gallery_id, 'add_extra_css', '' );
     336                echo '<textarea id="add_extra_css" name="add_extra_css" rows="10" class="large-text code">' . esc_textarea( $extra_css ) . '</textarea>';
     337                self::row_close( esc_html__( 'Paste your CSS code here. The gallery container HTML class is .spartan-gallery-wrapper', 'spartan-gallery' ) );
     338                self::section_close();
     339
     340                echo '</div>'; // .sg-options-content
     341                echo '</div>'; // .sg-options-wrap
     342        }
     343
     344        private static function split_length( $value, $default_num, $default_unit ) {
     345                $value = trim( (string) $value );
     346                if ( '' === $value ) {
     347                        return array( $default_num, $default_unit );
     348                }
     349                if ( preg_match( '/^(-?[0-9.]+)(px|em|rem|%|vh|vw)?$/', $value, $m ) ) {
     350                        return array( $m[1], isset( $m[2] ) ? $m[2] : $default_unit );
     351                }
     352                return array( $default_num, $default_unit );
     353        }
     354
     355        private static function unit_select( $name, $selected_unit ) {
     356                $out = '<select name="' . esc_attr( $name ) . '">';
     357                foreach ( array( 'px', 'em', 'rem', '%' ) as $unit ) {
     358                        $out .= '<option value="' . esc_attr( $unit ) . '" ' . selected( $selected_unit, $unit, false ) . '>' . esc_html( $unit ) . '</option>';
     359                }
     360                $out .= '</select>';
     361                return $out;
     362        }
     363
     364        public static function save( $post_id ) {
     365                if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
     366                        return;
     367                }
     368
     369                if ( ! isset( $_POST[ self::NONCE_NAME ] ) || ! wp_verify_nonce( wp_unslash( $_POST[ self::NONCE_NAME ] ), self::NONCE_ACTION ) ) {
     370                        return;
     371                }
     372
     373                if ( get_post_type( $post_id ) !== self::POST_TYPE ) {
     374                        return;
     375                }
     376
     377                if ( ! current_user_can( 'edit_post', $post_id ) ) {
     378                        return;
     379                }
     380
     381                $layout = isset( $_POST['image_layout_select'] ) ? sanitize_text_field( wp_unslash( $_POST['image_layout_select'] ) ) : 'value-1';
     382                if ( ! in_array( $layout, array( 'value-1', 'value-2', 'value-3', 'value-4', 'value-5', 'value-6' ), true ) ) {
     383                        $layout = 'value-1';
     384                }
     385                update_post_meta( $post_id, 'image_layout_select', $layout );
     386
     387                if ( isset( $_POST['spartan_gallery_uploaded_images'] ) ) {
     388                        $ids = array_filter( array_map( 'absint', explode( ',', wp_unslash( $_POST['spartan_gallery_uploaded_images'] ) ) ) );
     389                        update_post_meta( $post_id, 'spartan_gallery_uploaded_images', implode( ',', $ids ) );
     390                }
     391
     392                update_post_meta( $post_id, 'display_original', isset( $_POST['display_original'] ) ? '1' : '' );
     393                update_post_meta( $post_id, 'thumbnail_options', isset( $_POST['thumbnail_options'] ) ? '1' : '' );
     394                update_post_meta( $post_id, 'container_settings_on_off', isset( $_POST['container_settings_on_off'] ) ? '1' : '' );
     395
     396                update_post_meta( $post_id, 'image_width', isset( $_POST['image_width'] ) ? min( 2000, absint( $_POST['image_width'] ) ) : 150 );
     397                update_post_meta( $post_id, 'image_height', isset( $_POST['image_height'] ) ? min( 2000, absint( $_POST['image_height'] ) ) : 150 );
     398                update_post_meta( $post_id, 'img_margin', isset( $_POST['img_margin'] ) ? min( 100, absint( $_POST['img_margin'] ) ) : 20 );
     399
     400                $measure = isset( $_POST['image_measure_value'] ) ? sanitize_text_field( wp_unslash( $_POST['image_measure_value'] ) ) : 'px';
     401                update_post_meta( $post_id, 'image_measure_value', in_array( $measure, array( 'px', '%', 'vh', 'rem' ), true ) ? $measure : 'px' );
     402
     403                $thumb_size = isset( $_POST['thumbnail_size'] ) ? sanitize_text_field( wp_unslash( $_POST['thumbnail_size'] ) ) : 'medium_large';
     404                update_post_meta( $post_id, 'thumbnail_size', in_array( $thumb_size, array( 'thumbnail', 'medium', 'medium_large', 'large', 'original' ), true ) ? $thumb_size : 'medium_large' );
     405
     406                $container_bg = isset( $_POST['container_background_color'] ) ? sanitize_hex_color( wp_unslash( $_POST['container_background_color'] ) ) : '';
     407                update_post_meta( $post_id, 'container_background_color', $container_bg ? $container_bg : '#FFFFFF' );
     408
     409                $w_num  = isset( $_POST['container_width_num'] ) ? sanitize_text_field( wp_unslash( $_POST['container_width_num'] ) ) : '';
     410                $w_unit = isset( $_POST['container_width_unit'] ) ? sanitize_text_field( wp_unslash( $_POST['container_width_unit'] ) ) : 'px';
     411                $h_num  = isset( $_POST['container_height_num'] ) ? sanitize_text_field( wp_unslash( $_POST['container_height_num'] ) ) : '';
     412                $h_unit = isset( $_POST['container_height_unit'] ) ? sanitize_text_field( wp_unslash( $_POST['container_height_unit'] ) ) : 'px';
     413                update_post_meta(
     414                        $post_id,
     415                        'container_height_width_range',
    81416                        array(
    82                                 'title'  => esc_html__( 'Color Field', 'your-textdomain-here' ),
    83                                 'desc'   => esc_html__( 'Redux Framework was created with the developer in mind. It allows for any theme developer to have an advanced theme panel with most of the features a developer would need. For more information check out the Github repo at:', 'your-textdomain-here' ) . '  <a href="https://github.com/ReduxFramework/Redux-Framework">https://github.com/ReduxFramework/Redux-Framework</a>',
    84                                 'icon'   => 'el-icon-pencil',
    85                                 'id'     => 'color-section',
    86                                 'fields' => array(
    87                                         array(
    88                                                 'id'       => 'opt-color',
    89                                                 'type'     => 'color',
    90                                                 'title'    => esc_html__( 'Color Field', 'your-textdomain-here' ),
    91                                                 'default'  => '#333333',
    92                                                 'required' => array( 'opt-layout', '=', 'on' ),
    93                                         ),
    94                                 ),
    95                         ),
    96                 ),
    97         )
    98 );
    99 
    100 // Metabox sidebar.
    101 Redux_Metaboxes::set_box(
    102         $opt_name,
    103         array(
    104                 'id'         => 'opt-metaboxes-3',
    105                 'post_types' => array( 'spartan_gallery_type' ),
    106                 'position'   => 'side', // normal, advanced, side.
    107                 'priority'   => 'high', // high, core, default, low.
    108                 'sections'   => array(
    109                         array(
    110                                 'id'         => 'test-sidebar',
    111                                 'icon_class' => 'icon-large',
    112                                 'icon'       => 'el-icon-home',
    113                                 'fields'     => array(
    114                                         array(
    115                                                 'id'      => 'sidebar',
    116                                                 'title'   => esc_html__( 'Sidebar', 'your-textdomain-here' ),
    117                                                 'desc'    => esc_html__( 'Please select the sidebar you would like to display on this page. Note: You must first create the sidebar under Appearance > Widgets.', 'your-textdomain-here' ),
    118                                                 'type'    => 'select',
    119                                                 'data'    => 'sidebars',
    120                                                 'default' => 'None',
    121                                         ),
    122                                 ),
    123                         ),
    124                 ),
    125         )
    126 );
    127 */
    128 // Standard metabox.
    129 Redux_Metaboxes::set_box(
    130         $opt_name,
    131         array(
    132                 'id'         => 'opt-metaboxes-4',
    133                 'title'      => esc_html__( 'Spartan Gallery Options', 'your-textdomain-here' ),
    134                 'post_types' => array( 'spartan_gallery_type' ), // Define post types where this metabox will appear
    135                 'position'   => 'normal', // normal, advanced, side.
    136                 'priority'   => 'high',   // high, core, default, low.
    137                 'sections'   => array(
    138                         // Spartan Gallery First Section
    139                         array(
    140                                 'title'  => esc_html__( 'Gallery Layout Options', 'your-textdomain-here' ),
    141                                 'id'     => 'spartan_gallery_first_section',
    142                                 'icon'   => 'fa-solid fa-bars',
    143                                 'fields' => array(
    144                                         array(
    145                                                 'id'       => 'image_layout_select',
    146                                                 'type'     => 'image_select',
    147                                                 'title'    => esc_html__( 'Select Gallery Layout', 'your-textdomain-here' ),
    148                                                 'subtitle'      => esc_html__( 'Here you select layout of the gallery.
    149                                                         Gallery layout looks exactly like on the image. If you wish to change the apect radio of gallery, select the
    150                                                         third image and click "Display Adjustable Image" ON under "Image options" and switch "Display thumbnail size" OFF. From there you could change image width and height. This settings works
    151                                                         only with third and sixth layout. In other layouts image size are generated randomly for the grid.', 'your-textdomain-here' ),
    152                                                 'options'  => array(
    153                                                         'value-1' => plugins_url( '/img/FlexFreewallTable.png',  __FILE__ ),
    154                                                         'value-2' => plugins_url( '/img/ImageFreewallGrid.png',  __FILE__ ),
    155                                                         'value-3' => plugins_url( 'img/NestedFreewallGrid.png',  __FILE__ ),
    156                                                         'value-4' => plugins_url( '/img/PinterestFreewallGrid.png',  __FILE__ ),
    157                                                         'value-5' => plugins_url( '/img/hexagon_layout.jpg',  __FILE__ ),
    158                                                         'value-6' => plugins_url( '/img/spartan_3D_layout.png',  __FILE__ ),
    159                                                 ),
    160                                                 'radio'    => true,
    161                                                 'default'  => 'value-1',
    162                                         ),
    163                                 ),
    164                         ),
    165 
    166                         // Spartan Gallery Second Section
    167                         array(
    168                                 'title'  => esc_html__( 'Upload Images', 'your-textdomain-here' ),
    169                                 'id'     => 'spartan_gallery_second_section',
    170                                 'icon'   => 'fa-regular fa-image',
    171                                 'fields' => array(
    172                                         array(
    173                                                 'id'      => 'spartan_gallery_uploaded_images',
    174                                                 'type'    => 'gallery',
    175                                                 'title'   => esc_html__( 'Upload', 'your-textdomain-here' ),
    176                                                 'options' => array(
    177                                                         'attach'      => true,
    178                                                         'filecount'   => '101',
    179                                                         'auto-upload' => true,
    180                                                 ),
    181                                         ),
    182                                        
    183                                 ),
    184                         ),
    185 
    186                         // Image Options
    187                         array(
    188                                 'title'  => esc_html__( 'Image Options', 'your-textdomain-here' ),
    189                                 'id'     => 'image_options',
    190                                 'icon'   => 'fa-solid fa-sliders',
    191                                 'fields' => array(
    192                                         array(
    193                                                 'id'      => 'display_original',
    194                                                 'type'    => 'switch',
    195                                                 'title'   => esc_html__( 'Display Adjustable Image', 'your-textdomain-here' ),
    196                                                 'subtitle'      => esc_html__( '"Display thumbnail size" setting cant be turned on when when this setting is turned on', 'your-textdomain-here' ),
    197                                                 'default' => false,
    198                                         ),
    199                                         array(
    200                                                 'id'      => 'image_width',
    201                                                 'type'          => 'slider',
    202                                                 'title'         => esc_html__( 'Image width Steps (1) PX', 'your-textdomain-here' ),
    203                                                 //'subtitle'      => esc_html__( 'px', 'your-textdomain-here' ),
    204                                                 //'desc'          => esc_html__( 'Slider description. Min: 0, max: 800, step: 5, default value: 75', 'your-textdomain-here' ),
    205                                                 'default'       => 150,
    206                                                 'min'           => 0,
    207                                                 'step'          => 1,
    208                                                 'max'           => 2000,
    209                                                 'display_value' => 'text',
    210                                                 'output'        => array( '.site-content' => 'max-width' ),
    211                                         ),
    212                                         array(
    213                                                 'id'      => 'image_height',
    214                                                 'type'          => 'slider',
    215                                                 'title'         => esc_html__( 'Image height Steps (1) PX', 'your-textdomain-here' ),
    216                                                 //'subtitle'      => esc_html__( 'px', 'your-textdomain-here' ),
    217                                                 //'desc'          => esc_html__( 'Slider description. Min: 0, max: 800, step: 5, default value: 75', 'your-textdomain-here' ),
    218                                                 'default'       => 150,
    219                                                 'min'           => 0,
    220                                                 'step'          => 1,
    221                                                 'max'           => 2000,
    222                                                 'display_value' => 'text',
    223                                                 'output'        => array( '.site-content' => 'max-width' ),
    224                                         ),
    225                                         array(
    226                                                 'id'             => 'image_measure_value',
    227                                                 'type'           => 'select',
    228                                                 'title'          => esc_html__( 'Img measure value', 'your-textdomain-here' ),
    229                                                 'options'        => array(
    230                                                         'px'   => 'px',
    231                                                         '%'    => '%',
    232                                                         'vh'   => 'vh/vw',
    233                                                         'rem'  => 'rem',
    234                                                 ),
    235                                                 'default_option' => esc_html__( 'Select image measure value', 'your-textdomain-here' ),
    236                                                 'default'        => 'px',
    237                                         ),
    238                                         array(
    239                                                 'id'      => 'thumbnail_options',
    240                                                 'type'    => 'switch',
    241                                                 'title'   => esc_html__( 'Display thumbnail size', 'your-textdomain-here' ),
    242                                                 'subtitle'      => esc_html__( '"Display Adjustable Image " setting cant be turned on when when this setting is turned on', 'your-textdomain-here' ),
    243                                                 'default' => true,
    244                                         ),
    245                                         array(
    246                                                 'id'             => 'thumbnail_size',
    247                                                 'type'           => 'select',
    248                                                 'title'          => esc_html__( 'Select Thumbnail Size', 'your-textdomain-here' ),
    249                                                 'options'        => array(
    250                                                         'thumbnail'      => 'Thumbnail (default 150px x 150px max)',
    251                                                         'medium'         => 'Medium resolution (default 300px x 300px max)',
    252                                                         'medium_large'   => 'Medium Large resolution (default 768px x 0px max)',
    253                                                         'large'          => 'Large resolution (default 1024px x 1024px max)',
    254                                                         'original'       => 'Original image resolution (unmodified)',
    255                                                 ),
    256                                                 'default_option' => esc_html__( 'Select Image Thumbnail Size', 'your-textdomain-here' ),
    257                                                 'default'        => 'medium_large',
    258                                         ),
    259                                         array(
    260                                                 'id'      => 'img_margin',
    261                                                 'type'     => 'spinner',
    262                                                 'title'    => esc_html__('Image Margin (PX)', 'your-textdomain-here'),
    263                                                 //'subtitle' => esc_html__('No validation can be done on this field type','your-textdomain-here'),
    264                                                 //'desc'     => esc_html__('JQuery UI spinner description. Min:20, max: 100, step:20, default value: 40', 'your-textdomain-here'),
    265                                                 'default'  => '20',
    266                                                 'min'      => '0',
    267                                                 'step'     => '1',
    268                                                 'max'      => '100',
    269                                                 //'output'   => array( '.content-area' => 'max-width' ),
    270                                         ),
    271                                         /*
    272                                         array(
    273                                                 'id'      => 'img_border',
    274                                                 'type'     => 'border',
    275                                                 'title'    => esc_html__('Image Style Settings', 'your-project-name'),
    276                                                 //'subtitle' => esc_html__('Only color validation can be done on this field type', 'your-project-name'),
    277                                                 //'output'   => array('.site-header'),
    278                                                 'desc'     => esc_html__('This is the description field, again good for additional info.', 'your-project-name'),
    279                                                 'default'  => array(
    280                                                         'border-color'  => ' ',
    281                                                         'border-style'  => ' ',
    282                                                         'border-top'    => ' ',
    283                                                         'border-right'  => ' ',
    284                                                         'border-bottom' => ' ',
    285                                                         'border-left'   => ' '
    286     )
    287                                         ),
    288                                         */
    289                                 ),
    290                         ),
    291 
    292                         // Button Style Options
    293                         array(
    294                                 'title'  => esc_html__( 'Text Style Options', 'your-textdomain-here' ),
    295                                 'id'     => 'button_style_options',
    296                                 'icon'   => 'fa-solid fa-gears',
    297                                 'fields' => array(
    298                                         array(
    299                                                 'id'      => 'display_text',
    300                                                 'type'    => 'switch',
    301                                                 'title'   => esc_html__( 'Display text under image', 'your-textdomain-here' ),
    302                                                 'default' => false,
    303                                         ),
    304                                         array(
    305                                                 'id'      => 'textbox_height_range',
    306                                                 'type'          => 'slider',
    307                                                 'title'         => esc_html__( 'Text conteiner height, value is in %', 'your-textdomain-here' ),
    308                                                 //'subtitle'      => esc_html__( 'px', 'your-textdomain-here' ),
    309                                                 //'desc'          => esc_html__( 'Slider description. Min: 0, max: 800, step: 5, default value: 75', 'your-textdomain-here' ),
    310                                                 'default'       => 50,
    311                                                 'min'           => 0,
    312                                                 'step'          => 1,
    313                                                 'max'           => 100,
    314                                                 'display_value' => 'text',
    315                                                 //'output'        => array( '.site-content' => 'max-width' ),
    316                                         ),
    317                        
    318                                         array(
    319                                                 'id'     => 'info_background_color',
    320                                                 'type'     => 'color',
    321                                                 'title'    => esc_html__('Text box Background Color', 'your-textdomain-here'),
    322                                                 //'subtitle' => esc_html__('Pick a background color for the theme (default: #fff).', 'your-textdomain-here'),
    323                                                 'default'  => '#FFFFFF',
    324                                                 'validate' => 'color',
    325                                         ),
    326                                        
    327                                         array(
    328                                                  'id'      => 'font_family',
    329                                                 'type'        => 'typography',
    330                                                 'title'       => esc_html__('Typography', 'your-textdomain-here'),
    331                                                 'google'      => true,
    332                                                 'font-backup' => false,
    333                                                 'font-subsets' => false,
    334                                                 //'output'      => array('h2.site-description'),
    335                                                 'units'       =>'px',
    336                                                 'subtitle'    => esc_html__('Text box typography.', 'your-textdomain-here'),
    337                                                 'default'     => array(
    338                                                         'color'       => '#333',
    339                                                         'font-style'  => '200',
    340                                                         'font-family' => 'Abel',
    341                                                         'google'      => true,
    342                                                         'font-size'   => '9px',
    343                                                         'line-height' => '0'
    344                                                 ),
    345                                         ),     
    346                                 ),
    347                         ),
    348 
    349                         array(
    350                                 'title'  => esc_html__( 'Gallery Container Settings', 'your-textdomain-here' ),
    351                                 'id'     => 'gallery_container_first_section',
    352                                 'icon'   => 'fa-solid fa-screwdriver-wrench',
    353                                 'fields' => array(
    354                                        
    355                                         array(
    356                                                 'id'      => 'container_settings_on_off',
    357                                                 'type'    => 'switch',
    358                                                 'title'   => esc_html__( 'Turn settings On/Off', 'your-textdomain-here' ),
    359                                                 'default' => false,
    360                                         ),
    361                                         array(
    362                                                 'id'      => 'container_height_width_range',
    363                                                 'type'     => 'dimensions',
    364                                                         'units'    => array('em','px','%'),
    365                                                         'title'    => esc_html__('Container dimensions (Width/Height) Option', 'your-textdomain-here'),
    366                                                         //'subtitle' => esc_html__('Allow your users to choose width, height, and/or unit.', 'your-textdomain-here'),
    367                                                         //'desc'     => esc_html__('Enable or disable any piece of this field. Width, Height, or Units.', 'your-textdomain-here'),
    368                                                         'output'   => array('.spartan-gallery-wrapper'),
    369                                                         'default'  => array(
    370                                                                 'Width'   => '200',
    371                                                                 'Height'  => ''
    372                                                         ),
    373                                         ),
    374                                         array(
    375                                                 'id'     => 'container_background_color',
    376                                                 'type'     => 'color',
    377                                                 'title'    => esc_html__('Background Color', 'your-textdomain-here'),
    378                                                 //'subtitle' => esc_html__('Pick a background color for the theme (default: #fff).', 'your-textdomain-here'),
    379                                                 //'output'   => array('.spartan-gallery-wrapper'),     
    380                                                
    381                                                 'default'  => '#FFFFFF',
    382                                                 'validate' => 'color',
    383                                         ),
    384                                         array(
    385                                                 'id'     => 'container_border',
    386                                                 'type'     => 'border',
    387                                                 'title'    => esc_html__('Border Option', 'your-project-name'),
    388                                                 //'subtitle' => esc_html__('Only color validation can be done on this field type', 'your-project-name'),
    389                                                 //'output'   => array('.spartan-gallery-wrapper'),
    390                                                 //'desc'     => esc_html__('.spartan-gallery-wrapper'.', 'your-project-name'),
    391                                                 'default'  => array(
    392                                                         'border-color'  => ' ',
    393                                                         'border-style'  => 'none',
    394                                                         'border-top'    => ' ',
    395                                                         'border-right'  => ' ',
    396                                                         'border-bottom' => ' ',
    397                                                         'border-left'   => ' '
    398                                                 ),
    399                                         ),
    400                                 ),
    401                         ),
    402 
    403                        
    404                         array(
    405                                 'title'  => esc_html__( 'Insert Custom CSS', 'your-textdomain-here' ),
    406                                 'id'     => 'insert_extra_css_section',
    407                                 'icon'   => 'fa-solid fa-bars-progress',
    408                                 'fields' => array(
    409                                         array(
    410                                                 'id'      => 'add_extra_css',
    411                                                 'type'     => 'ace_editor',
    412                                                 'title'    => esc_html__('CSS Code', 'your-project-name'),
    413                                                 'subtitle' => esc_html__('Paste your CSS code here. Image container HTML class is .spartan-gallery-wrapper', 'your-project-name'),
    414                                                 'desc'     => esc_html__('Image container HTML class is .spartan-gallery-wrapper', 'your-project-name'),
    415                                                 'mode'     => 'css',
    416                                                 'theme'    => 'monokai',
    417                                                 'desc'     => 'Possible modes can be found at https://ace.c9.io/.',
    418                                                 //'default'  => "#header{\nmargin: 0 auto;\n}"
    419                                         ),
    420                                        
    421                                 ),
    422                         ),
    423 
    424                         array(
    425                                 'title'  => esc_html__( 'Import/Export Options', 'your-textdomain-here' ),
    426                                 //'id'     => 'insert_extra_css_section',
    427                                 'icon'   => 'fa-solid fa-bars-progress',
    428                                 'fields' => array(
    429                                        
    430                                         array(
    431                                                 'id'            => 'opt-import-export',
    432                                                 'type'          => 'import_export',
    433                                                 'title'         => 'Import Export',
    434                                                 'subtitle'      => 'Save and restore your Redux options',
    435                                                 'full_width'    => false,
    436                                         ),
    437                                 ),
    438                         ),
    439 
    440 
    441                
    442 
    443 
    444 
    445                 ),
    446         )
    447 );
    448 
    449 
     417                                'width'  => ( '' !== $w_num && is_numeric( $w_num ) ) ? $w_num . $w_unit : '',
     418                                'height' => ( '' !== $h_num && is_numeric( $h_num ) ) ? $h_num . $h_unit : '',
     419                        )
     420                );
     421
     422                if ( isset( $_POST['container_border'] ) && is_array( $_POST['container_border'] ) ) {
     423                        $raw = wp_unslash( $_POST['container_border'] );
     424                        $style_allowed = array( 'none', 'solid', 'dashed', 'dotted', 'double', 'groove', 'ridge', 'inset', 'outset' );
     425                        $border_color  = isset( $raw['border-color'] ) ? sanitize_hex_color( $raw['border-color'] ) : '';
     426                        update_post_meta(
     427                                $post_id,
     428                                'container_border',
     429                                array(
     430                                        'border-color'  => $border_color ? $border_color : '#000000',
     431                                        'border-style'  => isset( $raw['border-style'] ) && in_array( $raw['border-style'], $style_allowed, true ) ? $raw['border-style'] : 'none',
     432                                        'border-top'    => isset( $raw['border-top'] ) ? sanitize_text_field( $raw['border-top'] ) : '',
     433                                        'border-right'  => isset( $raw['border-right'] ) ? sanitize_text_field( $raw['border-right'] ) : '',
     434                                        'border-bottom' => isset( $raw['border-bottom'] ) ? sanitize_text_field( $raw['border-bottom'] ) : '',
     435                                        'border-left'   => isset( $raw['border-left'] ) ? sanitize_text_field( $raw['border-left'] ) : '',
     436                                )
     437                        );
     438                }
     439
     440                if ( isset( $_POST['add_extra_css'] ) ) {
     441                        update_post_meta( $post_id, 'add_extra_css', wp_strip_all_tags( wp_unslash( $_POST['add_extra_css'] ) ) );
     442                }
     443        }
     444}
     445
     446Spartan_Gallery_Options::init();
  • spartan-gallery/tags/1.4.0/includes/class-spartan-gallery-activator.php

    r2145680 r3619020  
    2121 * @author     Freelancer Martin <developerforwebsites@gmail.com>
    2222 */
     23
     24if ( ! defined( 'WPINC' ) ) {
     25        die;
     26}
     27
    2328class Spartan_Gallery_Activator {
    2429
  • spartan-gallery/tags/1.4.0/includes/class-spartan-gallery-deactivator.php

    r2145680 r3619020  
    2121 * @author     Freelancer Martin <developerforwebsites@gmail.com>
    2222 */
     23
     24if ( ! defined( 'WPINC' ) ) {
     25        die;
     26}
     27
    2328class Spartan_Gallery_Deactivator {
    2429
  • spartan-gallery/tags/1.4.0/includes/class-spartan-gallery-i18n.php

    r2145680 r3619020  
    2525 * @author     Freelancer Martin <developerforwebsites@gmail.com>
    2626 */
     27
     28if ( ! defined( 'WPINC' ) ) {
     29        die;
     30}
     31
    2732class Spartan_Gallery_i18n {
    2833
  • spartan-gallery/tags/1.4.0/includes/class-spartan-gallery-loader.php

    r2145680 r3619020  
    2222 * @author     Freelancer Martin <developerforwebsites@gmail.com>
    2323 */
     24
     25if ( ! defined( 'WPINC' ) ) {
     26        die;
     27}
     28
    2429class Spartan_Gallery_Loader {
    2530
  • spartan-gallery/tags/1.4.0/includes/class-spartan-gallery.php

    r3204032 r3619020  
    2828 * @author     Freelancer Martin <developerforwebsites@gmail.com>
    2929 */
     30
     31if ( ! defined( 'WPINC' ) ) {
     32        die;
     33}
     34
    3035class Spartan_Gallery {
    3136
    … …  
    137142
    138143                /**
     144                 * The class responsible for the Spartan Gallery options metabox (native
     145                 * WordPress replacement for the previous Redux Framework panel).
     146                 */
     147                require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-spartan-gallery-options.php';
     148
     149                /**
    139150                 * The class responsible for defining all actions that occur in the admin area.
    140151                 */
    … …  
    234245                $plugin_i18n = new Spartan_Gallery_i18n();
    235246
    236                 $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
     247                $this->loader->add_action( 'init', $plugin_i18n, 'load_plugin_textdomain' );
    237248
    238249        }
  • spartan-gallery/tags/1.4.0/public/class-spartan-gallery-public.php

    r3204032 r3619020  
    186186                       
    187187
    188                         // Loop through each post ID
    189                         foreach (explode(',',$get_all_post_attachements) as $post_id) {
    190                                 // Retrieve the post object by ID
    191                                 $post = get_post($post_id);
    192 
    193                                 // Check if the post exists
    194                                 if ($post) {
    195                                         // Get the GUID of the post and push it into the array
    196                                         $post_guids[] = $post;
     188                        $post_guids = array();
     189                        if ( ! empty( $get_all_post_attachements ) ) {
     190                                foreach ( explode( ',', $get_all_post_attachements ) as $post_id ) {
     191                                        $post = get_post( absint( $post_id ) );
     192                                        if ( $post ) {
     193                                                $post_guids[] = $post;
     194                                        }
    197195                                }
     196                        }
     197
     198                        if ( empty( $post_guids ) ) {
     199                                return '<!-- spartan-gallery: no images -->';
    198200                        }
    199201
  • spartan-gallery/tags/1.4.0/public/css/freewall-main.css

    r2145680 r3619020  
    66}
    77
    8 .info {
    9        padding: 15px;
    10        color: #333;
    11      }
    12 
    13 
    148#freewall {
    159 top: 65px;
  • spartan-gallery/tags/1.4.0/public/css/spartan-gallery-public.css

    r3204032 r3619020  
    66.container {
    77  position: relative;
    8 
    9 }
    10 
    11 .info
    12 {
    13   color: black;
    148
    159}
  • spartan-gallery/tags/1.4.0/public/custom-columns.php

    r2145680 r3619020  
    7272      <tr><td>
    7373
    74       <span style="color:#183691;" ><code>[spartan_gallery  id="<code style="color:green;" ><?php print_r(get_the_ID()); ?></code>"]</code><code style="color:#A71D5D;" ></code>
     74      <span style="color:#183691;" ><code>[spartan_gallery  id="<code style="color:green;" ><?php echo absint( get_the_ID() ); ?></code>"]</code><code style="color:#A71D5D;" ></code>
    7575   </span>
    7676      </td>
  • spartan-gallery/tags/1.4.0/public/html-cointainer-outputs/class-3d-slider-html-container.php

    r3204032 r3619020  
    11<?php
    22if ( ! defined( 'WPINC' ) ) {
    3 
    43    die;
    5 
    64}
    7 
    85
    96Class ThreeD_Image_Slider
    107{
     8    static function ThreeDImageSlidet_Html_container( $attachments, $gallery_id )
     9    {
     10        $CSSClass = new Spartan_Gallery_Generated_CSS_Output();
    1111
    12   static function ThreeDImageSlidet_Html_container( $attachments, $gallery_id )
    13   {
     12        $image_options_add_extra_css         = get_post_meta( $gallery_id, 'add_extra_css', true );
     13        $image_options_display_original      = get_post_meta( $gallery_id, 'display_original', true );
     14        $image_options_thumbnail_options     = get_post_meta( $gallery_id, 'thumbnail_options', true );
     15        $image_options_thumbnail_size        = get_post_meta( $gallery_id, 'thumbnail_size', true );
     16        $image_options_image_width           = absint( get_post_meta( $gallery_id, 'image_width', true ) );
     17        $image_options_image_height          = absint( get_post_meta( $gallery_id, 'image_height', true ) );
     18        $image_options_image_measure_value   = get_post_meta( $gallery_id, 'image_measure_value', true );
     19        $safe_extra_css                      = wp_strip_all_tags( $image_options_add_extra_css );
    1420
    15     $CSSClass = new Spartan_Gallery_Generated_CSS_Output();
    16     $output = '';
     21        // A gallery whose Image Options were never saved (or saved before the
     22        // options-panel slider bug was fixed) can have these stored as 0, which
     23        // renders every slide at 0px and makes the whole slider look empty.
     24        if ( ! $image_options_image_width ) {
     25            $image_options_image_width = 150;
     26        }
     27        if ( ! $image_options_image_height ) {
     28            $image_options_image_height = 150;
     29        }
    1730
    18     $image_options_add_extra_css = get_post_meta( $gallery_id , 'add_extra_css', true );
    19     $output .= '<style>'.$image_options_add_extra_css.'</style>';
    20    
    21     $output .= '<div style="'.$CSSClass->output_php_Css($gallery_id).'" class="spartan-gallery-wrapper w-gallery">';
    22       $output .= '<article id="demo-carousel" class="demo">';
    23         //$output .= '<a class="responsiveGallery-btn responsiveGallery-btn_prev" href="javascript:void(0);"></a>';
    24         //$output .= '<a class="responsiveGallery-btn responsiveGallery-btn_next" href="javascript:void(0);"></a>';
     31        $allowed_measure_values = array( 'px', '%', 'em', 'rem', 'vw', 'vh' );
     32        $image_measure_value    = in_array( $image_options_image_measure_value, $allowed_measure_values, true )
     33            ? $image_options_image_measure_value
     34            : 'px';
     35
     36        $output = '';
     37        $output .= '<style>' . $safe_extra_css . '</style>';
     38        $output .= '<div style="' . $CSSClass->output_php_Css( $gallery_id ) . '" class="spartan-gallery-wrapper w-gallery">';
     39        $output .= '<article id="demo-carousel" class="demo">';
    2540        $output .= '<div id="carousel">';
    26           $output .= '<ul class="flip-items">';
    27           if ( isset( $attachments ) && ! empty( $attachments )  )
    28           {
     41        $output .= '<ul class="flip-items">';
     42
     43        if ( isset( $attachments ) && ! empty( $attachments ) ) {
    2944            foreach ( $attachments as $attachments_id => $attachment_val ) {
    3045
    31               $img_size = array( '120', '160', '180', '240', '280', '320'   );
    32               $image_options_display_original = get_post_meta( $gallery_id , 'display_original', true ); // array
    33               $image_options_img_margin = get_post_meta( $gallery_id , 'img_margin', true );
    34               $image_options_thumbnail_options = get_post_meta( $gallery_id , 'thumbnail_options', true );
    35               $image_options_textbox_height_range = get_post_meta( $gallery_id , 'textbox_height_range', true );
    36               $image_options_display_text = get_post_meta( $gallery_id , 'display_text', true );
    37               $image_options_info_background_color = get_post_meta( $gallery_id , 'info_background_color', true );
    38               $image_options_container_font_size = get_post_meta( $gallery_id , 'container_font_size', true );
    39               $image_options_thumbnail_size = get_post_meta( $gallery_id , 'thumbnail_size', true );
    40               $image_options_image_width = get_post_meta( $gallery_id , 'image_width', true );
    41               $image_options_image_height = get_post_meta( $gallery_id , 'image_height', true );
    42               $image_options_font_family = get_post_meta( $gallery_id , 'font_family', true );
    43               $image_options_image_measure_value = get_post_meta( $gallery_id , 'image_measure_value', true );
     46                $image_attributes = wp_get_attachment_image_src( $attachment_val->ID, $image_options_thumbnail_size );
    4447
    45               $image_attributes = wp_get_attachment_image_src( $attachment_val->ID , $image_options_thumbnail_size  );
     48                $output .= '<li href="' . esc_url( $attachment_val->guid ) . '" class="js-img-viwer" data-caption="" data-id="' . absint( $attachments_id ) . '">';
    4649
    47              
     50                if ( $image_options_display_original == true and $image_options_thumbnail_options == false ) {
     51                    $output .= '<img style="height:' . $image_options_image_height . $image_measure_value . '; width:' . $image_options_image_width . $image_measure_value . '; object-fit:cover; object-position:center;" src="' . esc_url( $attachment_val->guid ) . '" />';
     52                } elseif ( $image_options_thumbnail_options == true and $image_options_display_original == false ) {
     53                    $output .= '<img style="height:' . $image_options_image_height . $image_measure_value . '; width:' . $image_options_image_width . $image_measure_value . '; object-fit:cover; object-position:center;" src="' . esc_url( $image_attributes[0] ) . '" />';
     54                } else {
     55                    $output .= '<p>' . esc_html__( 'Image Options: "Display Original" or "Display Thumbnail" must be enabled, but not both simultaneously.', 'spartan-gallery' ) . '</p>';
     56                }
    4857
    49               $output .= '<li href="'.$attachment_val->guid.'"  class="js-img-viwer " data-caption="" data-id="'.$attachments_id.'">';
     58                $output .= '</li>';
     59            }
     60        }
    5061
    51                 if ( $image_options_display_original == true and $image_options_thumbnail_options == false )
    52                 {
     62        $output .= '</ul>';
     63        $output .= '</div>';
     64        $output .= '</article>';
     65        $output .= '</div>';
    5366
    54                   //$output .= '<a href="#" class="responsivGallery-link">';
    55                     $output .= '<img style="height:'.$image_options_image_height.''.$image_options_image_measure_value.';  width:'.$image_options_image_width.''.$image_options_image_measure_value.';" src="'.$attachment_val->guid.'"  />';
    56                   //$output .= '</a>';
    57 
    58                 }
    59                 elseif ( $image_options_thumbnail_options == true and $image_options_display_original == false )
    60                 {
    61 
    62                   //$output .= '<a href="#" class="responsivGallery-link">';
    63                     $output .= '<img style="height:'.$image_options_image_height.''.$image_options_image_measure_value.';  width:'.$image_options_image_width.''.$image_options_image_measure_value.';" src="'.$image_attributes[0].'"  />';
    64                   //$output .= '</a>';
    65 
    66                 }
    67                 else
    68                 {
    69                  
    70                   $output .=  '<p>Image Options => "Display Original Size Image" or "Display Thumnail Size" settings are turned on or off same time</p>';
    71 
    72                   print $text;
    73 
    74                 }
    75                 $output .= '<div style="color: black;" class="w-responsivGallery-info">';
    76                 if ( ! empty( $attachment_id ) and true == $image_options_display_text )
    77                 {
    78 
    79 
    80                   $html .= '<div class="info" >';
    81                     if( ! empty( $attachment_val->post_title))
    82                     {
    83                       $html .= '<h5 class="text spartan-gallery-img-title" >'.$attachment_val->post_title.'</h5>';
    84                     }
    85                     if( ! empty( $attachment_val->post_content))  {
    86                       $html .= '<p class="text spartan-gallery-img-description" >'.$attachment_val->post_content.'</p>';
    87                     }
    88                    
    89                     if( ! empty( $attachment_val->guid ) ) {
    90                       $html .= ('<td colspan="3" style="background-color:#005673; text-align:right; padding: 4px 0px;">
    91                         <button class="spartan-gallery-img-button text" onclick="parent.open(\'' . $attachment_val->guid . '\')" >'.$attachment_val->post_title.'</button></td>');
    92                     }
    93                        
    94                   $html .= '</div>';
    95 
    96                 }
    97                 $output .= '</div>';
    98               $output .= '</li>';
    99 
    100             }
    101           }
    102           $output .= '</ul>';
    103           $output .= '</div>';
    104         $output .= '</article>';
    105       $output .= '</div>';
    106 
    107       $output .=
    108         '
     67        $output .= '
    10968        <script>
    11069        jQuery( document ).ready( function( $ ){
    111           var carousel = $("#carousel").flipster({
     70            var carousel = $("#carousel").flipster({
    11271                style: "carousel",
    11372                spacing: -0.2,
    114                
    115                 buttons:   true,
     73                buttons: true,
    11674            });
    117             });
     75        });
    11876        </script>';
    11977
    120       return $output;
    121 
    122 
    123 
    124 
    125   }
    126 
    127 
     78        return $output;
     79    }
    12880}
  • spartan-gallery/tags/1.4.0/public/html-cointainer-outputs/class-freewall-chaotic-output.php

    r3204032 r3619020  
    11<?php
    22if ( ! defined( 'WPINC' ) ) {
    3 
    43    die;
    5 
    64}
    7 
    85
    96Class Freewall_Chaotic_Container
    107{
    11      
     8    static function display_chaotic_html_container( $attachments, $gallery_id )
     9    {
     10        $CSSClass = new Spartan_Gallery_Generated_CSS_Output();
    1211
     12        $image_options_add_extra_css         = get_post_meta( $gallery_id, 'add_extra_css', true );
     13        $image_options_display_original      = get_post_meta( $gallery_id, 'display_original', true );
     14        $image_options_img_margin            = absint( get_post_meta( $gallery_id, 'img_margin', true ) );
     15        $image_options_thumbnail_options     = get_post_meta( $gallery_id, 'thumbnail_options', true );
     16        $image_options_thumbnail_size        = get_post_meta( $gallery_id, 'thumbnail_size', true );
     17        $safe_extra_css                      = wp_strip_all_tags( $image_options_add_extra_css );
    1318
    14       static function display_chaotic_html_container( $attachments, $gallery_id )
    15       {
     19        $html = '';
     20        $html .= '<style>' . $safe_extra_css . '</style>';
     21        $html .= '<div style="' . $CSSClass->output_php_Css( $gallery_id ) . '" class="spartan-gallery-wrapper">';
     22        $html .= '<div id="freewall-chaotic" class="masonary">';
    1623
    17         $CSSClass = new Spartan_Gallery_Generated_CSS_Output();
    18                           //$CSSClass->output_php_Css($spartan_gallery_post_type['post_parent']);
    19        
    20         $html = '';
    21         $image_options_add_extra_css = get_post_meta( $gallery_id , 'add_extra_css', true );
    22         $html .= '<style>
    23         '.$image_options_add_extra_css.' 
    24                           </style>';
    25         $html .= '  <div style="'.$CSSClass->output_php_Css($gallery_id).'" class="spartan-gallery-wrapper" >';
    26           $html .= '  <div id="freewall-chaotic" class="masonary" >'; //data-fixSize="true"
    27           // Loop through them and output an image
    28             $img_size = array( '120', '160', '180', '240', '280', '320'   );
     24        $img_size = array( '120', '160', '180', '240', '280', '320' );
    2925
    30             foreach ( (array) $attachments as $attachment_id => $attachment_val ) {
    31               //Settings variables for from database
    32               $img_size = array( '120', '160', '180', '240', '280', '320'   );
    33               $image_options_display_original = get_post_meta( $gallery_id , 'display_original', true ); // array
    34               $image_options_img_margin = get_post_meta( $gallery_id , 'img_margin', true );
    35               $image_options_thumbnail_options = get_post_meta( $gallery_id , 'thumbnail_options', true );
    36               $image_options_textbox_height_range = get_post_meta( $gallery_id , 'textbox_height_range', true );
    37               $image_options_display_text = get_post_meta( $gallery_id , 'display_text', true );
    38               $image_options_info_background_color = get_post_meta( $gallery_id , 'info_background_color', true );
    39               $image_options_container_font_size = get_post_meta( $gallery_id , 'container_font_size', true );
    40               $image_options_thumbnail_size = get_post_meta( $gallery_id , 'thumbnail_size', true );
    41               $image_options_font_family = get_post_meta( $gallery_id , 'font_family', true );
    42              
    43              
    44               $image_attributes = wp_get_attachment_image_src( $attachment_val->ID , $image_options_thumbnail_size  );
    45               //print_r( $image_options_add_extra_css);
    46              
    47               if ( $image_options_display_original == true xor $image_options_thumbnail_options == true ) {
     26        foreach ( (array) $attachments as $attachment_id => $attachment_val ) {
    4827
    49                 $html .=  '<div  class="freewall-brick-chaotic brick"  data-width="'.$img_size[array_rand( $img_size , 1 )].'" data-height="'.$img_size[array_rand( $img_size , 1 )].'" data-delay="'.$attachment_id.'"   >';
    50 
    51               }
    52 
    53               $html .=  '<a  href="'.$attachment_val->guid.'"  class="js-img-viwer img-true-location" data-caption="" data-id="'.$attachment_id.'" >';
    54                   //=====================  Random width layout   =============================
    55                  
    56                   if ( $image_options_display_original == true and $image_options_thumbnail_options == false ) {
    57 
    58                     $html .= '<img class="image" style="height:100%;  width:100%;" src="'.$attachment_val->guid.'"  />';
    59                    
    60                   } elseif ( $image_options_thumbnail_options == true and $image_options_display_original == false ) {
    61 
    62                     $html .= '<img class="image" style="height:100%;  width:100%;" src="'.$image_attributes[0].'"  />';
    63 
    64                   } else
    65                   {
    66                     $text =  '<p>Image Options => "Display Original Size Image" or "Display Thumnail Size" settings are turned on or off same time</p>';
    67                     //print $text;
    68                     return $text;
    69                   }
    70 
    71 
    72                   //$s = get_post_meta( get_the_ID(),"imgtitle" . $attachment_val->ID, true );
    73 
    74                   if ( ! empty( $attachment_id ) and true == $image_options_display_text ) {
    75                       if( true == $image_options_display_text ) {
    76                           $html .= '<style>
    77                             .image
    78                             {
    79                               max-height: calc( 100% - '.$image_options_textbox_height_range.'% ) !important;
    80                             }
    81                             .info
    82                             {
    83                               max-height: calc( 100% - '.$image_options_textbox_height_range.'% ) !important;
    84                               background-color: '.$image_options_info_background_color.';
    85                               position: relative;
    86                               margin: 0px;
    87                               font-size: '.$image_options_container_font_size.'px !important ;
    88                             }
    89                            
    90                             .info>p
    91                             {
    92                               font-size: '.$image_options_font_family['font-size'].';
    93                               color:      '.$image_options_font_family['color'].';
    94                               font-style:  '.$image_options_font_family['font-style'].';
    95                               font-family: '.$image_options_font_family['font-family'] .';
    96                               line-height:  '.$image_options_font_family['line-height'].';
    97                               font-weight: '.$image_options_font_family['font-weight'].';
    98                               text-align: '.$image_options_font_family['text-align'].';
    99                             }
    100                            
    101                             .info>h5
    102                             {
    103                               font-size: '.$image_options_font_family['font-size'].';
    104                               color:      '.$image_options_font_family['color'].';
    105                               font-style:  '.$image_options_font_family['font-style'].';
    106                               font-family: '.$image_options_font_family['font-family'] .';
    107                               line-height:  '.$image_options_font_family['line-height'].';
    108                               font-weight: '.$image_options_font_family['font-weight'].';
    109                               text-align: '.$image_options_font_family['text-align'].';
    110                             }
    111 
    112                             .info>button
    113                             {
    114                               font-size: '.$image_options_font_family['font-size'].';
    115                               color:      '.$image_options_font_family['color'].';
    116                              
    117                             }
    118                             '.$image_options_add_extra_css.' 
    119                           </style>';
    120                          
    121                         }
    122 
    123                       $html .= '<div class="info" >';
    124                           if( ! empty( $attachment_val->post_title))
    125                           {
    126                             $html .= '<h5 class="text spartan-gallery-img-title" >'.$attachment_val->post_title.'</h5>';
    127                           }
    128                           if( ! empty( $attachment_val->post_content))  {
    129                             $html .= '<p class="text spartan-gallery-img-description" >'.$attachment_val->post_content.'</p>';
    130                           }
    131                          
    132                           if( ! empty( $attachment_val->guid ) ) {
    133                             $html .= ('<td colspan="3" style="background-color:#005673; text-align:right; padding: 4px 0px;">
    134                               <button class="spartan-gallery-img-button text" onclick="parent.open(\'' . $attachment_val->guid . '\')" >'.$attachment_val->post_title.'</button></td>');
    135                           }
    136                              
    137                        $html .= '</div>';
    138 
    139                     }
    140 
    141               $html .= '</a>';
    142 
    143 
     28            $image_attributes = wp_get_attachment_image_src( $attachment_val->ID, $image_options_thumbnail_size );
    14429
    14530            if ( $image_options_display_original == true xor $image_options_thumbnail_options == true ) {
    146               $html .= '</div>';
     31                $brick_w_index = array_rand( $img_size, 1 );
     32                $brick_h_index = wp_rand( max( 0, $brick_w_index - 1 ), min( count( $img_size ) - 1, $brick_w_index + 1 ) );
     33                $html .= '<div class="freewall-brick-chaotic brick" data-width="' . $img_size[ $brick_w_index ] . '" data-height="' . $img_size[ $brick_h_index ] . '" data-delay="' . absint( $attachment_id ) . '">';
    14734            }
    14835
     36            $html .= '<a href="' . esc_url( $attachment_val->guid ) . '" class="js-img-viwer img-true-location" data-caption="" data-id="' . absint( $attachment_id ) . '">';
    14937
     38            if ( $image_options_display_original == true and $image_options_thumbnail_options == false ) {
     39                $html .= '<img class="image" style="height:100%; width:100%; object-fit:cover; object-position:center;" loading="lazy" src="' . esc_url( $attachment_val->guid ) . '" />';
     40            } elseif ( $image_options_thumbnail_options == true and $image_options_display_original == false ) {
     41                $html .= '<img class="image" style="height:100%; width:100%; object-fit:cover; object-position:center;" loading="lazy" src="' . esc_url( $image_attributes[0] ) . '" />';
     42            } else {
     43                return '<p>' . esc_html__( 'Image Options: "Display Original" or "Display Thumbnail" must be enabled, but not both simultaneously.', 'spartan-gallery' ) . '</p>';
     44            }
    15045
     46            $html .= '</a>';
     47
     48            if ( $image_options_display_original == true xor $image_options_thumbnail_options == true ) {
     49                $html .= '</div>';
    15150            }
    152             $html .= '</div>';
    153           $html .= '</div>';
     51        }
    15452
    155           $html .= '';
    156           $html .= '<script>';
    157             $html .= 'jQuery( document ).ready( function( $ ){';
     53        $html .= '</div>';
     54        $html .= '</div>';
    15855
    159               // chaotic layout
    160                 $html .= '$(".freewall-brick-chaotic").each(function() {';
    161                     $html .= 'var wall = new Freewall("#freewall-chaotic");';
    162                     $html .= 'wall.reset({';
    163                         $html .= 'animate: true,';
    164                         $html .= 'cellW: 150,';
    165                         $html .= 'cellH: 150,';
    166                         //fixSize: 1,
    167                         $html .= 'gutterY: '.$image_options_img_margin.',';
    168                         $html .= 'gutterX: '.$image_options_img_margin.',';
    169                         $html .=  'onResize: function() {';
    170                             $html .= 'wall.fitWidth();';
    171                         $html .= '}';
    172                     $html .= '});';
    173                     $html .= 'wall.addCustomEvent("onBlockLoad", function(setting) {';
    174                         $html .= 'console.log(setting);';
    175                     $html .= '});';
    176                     $html .= 'wall.fitWidth();';
    177                 $html .= '});';
     56        $html .= '<script>
     57            jQuery( document ).ready( function( $ ){
     58                $(".freewall-brick-chaotic").each(function() {
     59                    var wall = new Freewall("#freewall-chaotic");
     60                    wall.reset({
     61                        animate: true,
     62                        cellW: 150,
     63                        cellH: 150,
     64                        gutterY: ' . $image_options_img_margin . ',
     65                        gutterX: ' . $image_options_img_margin . ',
     66                        onResize: function() {
     67                            wall.fitWidth();
     68                        }
     69                    });
     70                    wall.fitWidth();
     71                });
     72            });
     73        </script>';
    17874
    179             $html .= ' });';
    180             $html .= '</script>';
    181 
    182             return $html;
    183 
    184 
    185       }
    186 
    187 
    188 
    189 
     75        return $html;
     76    }
    19077}
  • spartan-gallery/tags/1.4.0/public/html-cointainer-outputs/class-freewall-fixed-img-output.php

    r3204032 r3619020  
    11<?php
    22if ( ! defined( 'WPINC' ) ) {
    3 
    43    die;
    5 
    64}
    7 
    85
    96Class Freewall_Fixed_Img_Container
    107{
     8    static function display_fixed_img_container( $attachments, $gallery_id )
     9    {
     10        $CSSClass = new Spartan_Gallery_Generated_CSS_Output();
    1111
     12        $image_options_add_extra_css         = get_post_meta( $gallery_id, 'add_extra_css', true );
     13        $image_options_display_original      = get_post_meta( $gallery_id, 'display_original', true );
     14        $image_options_img_margin            = absint( get_post_meta( $gallery_id, 'img_margin', true ) );
     15        $image_options_thumbnail_options     = get_post_meta( $gallery_id, 'thumbnail_options', true );
     16        $image_options_thumbnail_size        = get_post_meta( $gallery_id, 'thumbnail_size', true );
     17        $image_options_image_width           = absint( get_post_meta( $gallery_id, 'image_width', true ) );
     18        $image_options_image_height          = absint( get_post_meta( $gallery_id, 'image_height', true ) );
     19        $safe_extra_css                      = wp_strip_all_tags( $image_options_add_extra_css );
    1220
    13       static function display_fixed_img_container( $attachments, $gallery_id   )
    14       {
    15         $CSSClass = new Spartan_Gallery_Generated_CSS_Output();
     21        // A gallery whose Image Options were never saved (or saved before the
     22        // options-panel slider bug was fixed) can have these stored as 0, which
     23        // renders zero-size bricks and makes the whole gallery look empty.
     24        if ( ! $image_options_image_width ) {
     25            $image_options_image_width = 150;
     26        }
     27        if ( ! $image_options_image_height ) {
     28            $image_options_image_height = 150;
     29        }
     30
    1631        $html = '';
    17         $image_options_add_extra_css = get_post_meta( $gallery_id , 'add_extra_css', true );
    18         $html .= '<style>'.$image_options_add_extra_css.'</style>';
    19         $html .= '  <div style="'.$CSSClass->output_php_Css($gallery_id).'" class="spartan-gallery-wrapper" >';
    20           $html .= '  <div id="freewall" class="masonary" >'; //data-fixSize="true"
    21           // Loop through them and output an image
     32        $html .= '<style>' . $safe_extra_css . '</style>';
     33        $html .= '<div style="' . $CSSClass->output_php_Css( $gallery_id ) . '" class="spartan-gallery-wrapper">';
     34        $html .= '<div id="freewall" class="masonary">';
    2235
    23             foreach ( (array) $attachments as $attachment_id => $attachment_val ) {
     36        foreach ( (array) $attachments as $attachment_id => $attachment_val ) {
    2437
    25               $img_size = array( '120', '160', '180', '240', '280', '320'   );
    26               $image_options_display_original = get_post_meta( $gallery_id , 'display_original', true ); // array
    27               $image_options_img_margin = get_post_meta( $gallery_id , 'img_margin', true );
    28               $image_options_thumbnail_options = get_post_meta( $gallery_id , 'thumbnail_options', true );
    29               $image_options_textbox_height_range = get_post_meta( $gallery_id , 'textbox_height_range', true );
    30               $image_options_display_text = get_post_meta( $gallery_id , 'display_text', true );
    31               $image_options_info_background_color = get_post_meta( $gallery_id , 'info_background_color', true );
    32               $image_options_container_font_size = get_post_meta( $gallery_id , 'container_font_size', true );
    33               $image_options_thumbnail_size = get_post_meta( $gallery_id , 'thumbnail_size', true );
    34               $image_options_image_width = get_post_meta( $gallery_id , 'image_width', true );
    35               $image_options_image_height = get_post_meta( $gallery_id , 'image_height', true );
    36               $image_options_font_family = get_post_meta( $gallery_id , 'font_family', true );
    37              
    38              
    39               $image_attributes = wp_get_attachment_image_src( $attachment_val->ID , $image_options_thumbnail_size  );
     38            $image_attributes = wp_get_attachment_image_src( $attachment_val->ID, $image_options_thumbnail_size );
    4039
    41               if ( $image_options_display_original == true xor $image_options_thumbnail_options == true )
    42               {
    43 
    44                 $html .=  '<div  class="freewall-brick brick overlay"  data-width="'.$image_options_image_width .'" data-height="'.$image_options_image_height.'" data-delay="'.$attachment_id.'"   >';
    45              
    46               }
    47 
    48               $html .=  '<a  href="'.$attachment_val->guid.'"  class="js-img-viwer img-true-location container" data-caption="" data-id="'.$attachment_id.'" >';
    49 
    50                   //=====================  Fixed Image layout   =============================
    51                   if ( $image_options_display_original == true and $image_options_thumbnail_options == false )
    52                   {
    53 
    54                     $html .= '<img class="image" style="height:100%;  width:100%;" src="'.$attachment_val->guid.'"  />';
    55 
    56                   } elseif ( $image_options_thumbnail_options == true and $image_options_display_original == false )
    57                   {
    58 
    59                     $html .= '<img class="image" style="height:100%;  width:100%;"  src="'.$image_attributes[0].'"  />';
    60 
    61                   } else
    62                   {
    63                     $text =  '<p>Image Options => "Display Original Size Image" or "Display Thumnail Size" settings are turned on or off same time</p>';
    64 
    65                     print $text;
    66                    
    67                   }
    68 
    69 
    70                   if ( ! empty( $attachment_id ) and true == $image_options_display_text ) {
    71                     if( true == $image_options_display_text ) {
    72                         $html .= '<style>
    73                           .image
    74                           {
    75                             max-height: calc( 100% - '.$image_options_textbox_height_range.'% ) !important;
    76                           }
    77                           .info
    78                           {
    79                             max-height: calc( 100% - '.$image_options_textbox_height_range.'% ) !important;
    80                             background-color: '.$image_options_info_background_color.';
    81                             position: relative;
    82                             margin: 0px;
    83                             font-size: '.$image_options_container_font_size.'px !important ;
    84                           }
    85                          
    86                           .info>p
    87                           {
    88                             font-size: '.$image_options_font_family['font-size'].';
    89                             color:      '.$image_options_font_family['color'].';
    90                             font-style:  '.$image_options_font_family['font-style'].';
    91                             font-family: '.$image_options_font_family['font-family'] .';
    92                             line-height:  '.$image_options_font_family['line-height'].';
    93                             font-weight: '.$image_options_font_family['font-weight'].';
    94                             text-align: '.$image_options_font_family['text-align'].';
    95                           }
    96                          
    97                           .info>h5
    98                           {
    99                             font-size: '.$image_options_font_family['font-size'].';
    100                             color:      '.$image_options_font_family['color'].';
    101                             font-style:  '.$image_options_font_family['font-style'].';
    102                             font-family: '.$image_options_font_family['font-family'] .';
    103                             line-height:  '.$image_options_font_family['line-height'].';
    104                             font-weight: '.$image_options_font_family['font-weight'].';
    105                             text-align: '.$image_options_font_family['text-align'].';
    106                           }
    107 
    108                           .info>button
    109                           {
    110                             font-size: '.$image_options_font_family['font-size'].';
    111                             color:      '.$image_options_font_family['color'].';
    112                            
    113                           }
    114                           '.$image_options_add_extra_css.' 
    115                         </style>';
    116                        
    117                       }
    118 
    119                     $html .= '<div class="info" >';
    120                         if( ! empty( $attachment_val->post_title))
    121                         {
    122                           $html .= '<h5 class="text spartan-gallery-img-title" >'.$attachment_val->post_title.'</h5>';
    123                         }
    124                         if( ! empty( $attachment_val->post_content))  {
    125                           $html .= '<p class="text spartan-gallery-img-description" >'.$attachment_val->post_content.'</p>';
    126                         }
    127                        
    128                         if( ! empty( $attachment_val->guid ) ) {
    129                           $html .= ('<td colspan="3" style="background-color:#005673; text-align:right; padding: 4px 0px;">
    130                             <button class="spartan-gallery-img-button text" onclick="parent.open(\'' . $attachment_val->guid . '\')" >'.$attachment_val->post_title.'</button></td>');
    131                         }
    132                            
    133                      $html .= '</div>';
    134 
    135                     }
    136 
    137               $html .= '</a>';
    138 
    139 
    140 
    141             if ( $image_options_display_original == true xor $image_options_thumbnail_options == true )
    142             {
    143               $html .= '</div>';
     40            if ( $image_options_display_original == true xor $image_options_thumbnail_options == true ) {
     41                $html .= '<div class="freewall-brick brick overlay" data-width="' . $image_options_image_width . '" data-height="' . $image_options_image_height . '" data-delay="' . absint( $attachment_id ) . '">';
    14442            }
    14543
     44            $html .= '<a href="' . esc_url( $attachment_val->guid ) . '" class="js-img-viwer img-true-location container" data-caption="" data-id="' . absint( $attachment_id ) . '">';
    14645
     46            if ( $image_options_display_original == true and $image_options_thumbnail_options == false ) {
     47                $html .= '<img class="image" style="height:100%; width:100%; object-fit:cover; object-position:center;" loading="lazy" src="' . esc_url( $attachment_val->guid ) . '" />';
     48            } elseif ( $image_options_thumbnail_options == true and $image_options_display_original == false ) {
     49                $html .= '<img class="image" style="height:100%; width:100%; object-fit:cover; object-position:center;" loading="lazy" src="' . esc_url( $image_attributes[0] ) . '" />';
     50            } else {
     51                return '<p>' . esc_html__( 'Image Options: "Display Original" or "Display Thumbnail" must be enabled, but not both simultaneously.', 'spartan-gallery' ) . '</p>';
    14752            }
    148             $html .= '</div>';
    149           $html .= '</div>';
    15053
     54            $html .= '</a>';
    15155
     56            if ( $image_options_display_original == true xor $image_options_thumbnail_options == true ) {
     57                $html .= '</div>';
     58            }
     59        }
    15260
    153           $html .= '';
    154           $html .= '<script>';
    155             $html .= 'jQuery( document ).ready( function( $ ){';
     61        $html .= '</div>';
     62        $html .= '</div>';
    15663
    157               // chaotic layout
    158                 $html .= '$(".freewall-brick").each(function() {';
    159                     $html .= 'var wall = new Freewall("#freewall");';
    160                     $html .= 'wall.reset({';
    161                         $html .= 'animate: true,';
    162                         //$script .='cellW: 100,';
    163                         //$script .='cellH: 100,';
    164                         //fixSize: 1,
    165                         $html .= 'gutterY: '.$image_options_img_margin.',';
    166                         $html .= 'gutterX: '.$image_options_img_margin.',';
    167                         $html .= 'onResize: function() {';
    168                             $html .= 'wall.fitWidth();';
    169                         $html .= '}';
    170                     $html .= '});';
    171                     $html .=  'wall.addCustomEvent("onBlockLoad", function(setting) {';
    172                         $html .= 'console.log(setting);';
    173                     $html .= '});';
    174                     $html .= 'wall.fitWidth();';
    175                 $html .= '});';
     64        $html .= '<script>';
     65        $html .= 'jQuery( document ).ready( function( $ ){';
     66        $html .= '$(".freewall-brick").each(function() {';
     67        $html .= 'var wall = new Freewall("#freewall");';
     68        $html .= 'wall.reset({';
     69        $html .= 'animate: true,';
     70        $html .= 'gutterY: ' . $image_options_img_margin . ',';
     71        $html .= 'gutterX: ' . $image_options_img_margin . ',';
     72        $html .= 'onResize: function() {';
     73        $html .= 'wall.fitWidth();';
     74        $html .= '}';
     75        $html .= '});';
     76        $html .= 'wall.fitWidth();';
     77        $html .= '});';
     78        $html .= '});';
     79        $html .= '</script>';
    17680
    177             $html .= ' });';
    178 
    179            $html .= '</script>';
    180 
    181            return $html;
    182       }
    183 
    184 
    185 
     81        return $html;
     82    }
    18683}
  • spartan-gallery/tags/1.4.0/public/html-cointainer-outputs/class-freewall-pinterest-output.php

    r3204032 r3619020  
    11<?php
    22if ( ! defined( 'WPINC' ) ) {
    3 
    43    die;
    5 
    64}
    7 
    85
    96Class Freewall_Pinterest_Container
    107{
    11 
    12       static function display_pinterest_container( $attachments , $gallery_id )
    13       {
     8    static function display_pinterest_container( $attachments, $gallery_id )
     9    {
    1410        $CSSClass = new Spartan_Gallery_Generated_CSS_Output();
    1511
     12        $image_options_add_extra_css         = get_post_meta( $gallery_id, 'add_extra_css', true );
     13        $image_options_display_original      = get_post_meta( $gallery_id, 'display_original', true );
     14        $image_options_img_margin            = absint( get_post_meta( $gallery_id, 'img_margin', true ) );
     15        $image_options_thumbnail_options     = get_post_meta( $gallery_id, 'thumbnail_options', true );
     16        $image_options_thumbnail_size        = get_post_meta( $gallery_id, 'thumbnail_size', true );
     17        $safe_extra_css                      = wp_strip_all_tags( $image_options_add_extra_css );
     18
    1619        $html = '';
     20        $html .= '<style>' . $safe_extra_css . '</style>';
     21        $html .= '<div style="' . $CSSClass->output_php_Css( $gallery_id ) . '" class="spartan-gallery-wrapper">';
     22        $html .= '<div id="freewall-pinterest" class="masonary">';
    1723
    18         $image_options_add_extra_css = get_post_meta( $gallery_id , 'add_extra_css', true );
    19         $html .= '<style>'.$image_options_add_extra_css.'</style>';
     24        $img_size = array( '120', '160', '180', '240', '280', '320' );
    2025
    21         $html .= '  <div style="'.$CSSClass->output_php_Css($gallery_id).'" class="spartan-gallery-wrapper" >';
    22           $html .= '  <div id="freewall-pinterest" class="masonary" >'; //data-fixSize="true"
    23           // Loop through them and output an image
    24             $img_size = array( '120', '160', '180', '240', '280', '320'   );
     26        foreach ( (array) $attachments as $attachment_id => $attachment_val ) {
    2527
    26             foreach ( (array) $attachments as $attachment_id => $attachment_val ) {
     28            $image_attributes = wp_get_attachment_image_src( $attachment_val->ID, $image_options_thumbnail_size );
    2729
    28                 $img_size = array( '120', '160', '180', '240', '280', '320'   );
    29                 //Settings variables for from database
    30                
    31                 $image_options_display_original = get_post_meta( $gallery_id , 'display_original', true ); // array
    32                 $image_options_img_margin = get_post_meta( $gallery_id , 'img_margin', true );
    33                 $image_options_thumbnail_options = get_post_meta( $gallery_id , 'thumbnail_options', true );
    34                 $image_options_textbox_height_range = get_post_meta( $gallery_id , 'textbox_height_range', true );
    35                 $image_options_display_text = get_post_meta( $gallery_id , 'display_text', true );
    36                 $image_options_info_background_color = get_post_meta( $gallery_id , 'info_background_color', true );
    37                 $image_options_container_font_size = get_post_meta( $gallery_id , 'container_font_size', true );
    38                 $image_options_thumbnail_size = get_post_meta( $gallery_id , 'thumbnail_size', true );
    39                 $image_options_font_family = get_post_meta( $gallery_id , 'font_family', true );
    40              
    41              
    42                 $image_attributes = wp_get_attachment_image_src( $attachment_val->ID , $image_options_thumbnail_size  );
    43 
    44                 if ( $image_options_display_original == true xor $image_options_thumbnail_options == true )
    45                 {
    46                  
    47                   $html .=  '<div  class="freewall-brick-pinterest brick"  data-width="'.$img_size[array_rand( $img_size , 1 )].'" data-height="'.$img_size[array_rand( $img_size , 1 )].'" data-delay="'.$attachment_id.'"   >';
    48                
    49                 }
    50 
    51                 $html .=  '<a  href="'.$attachment_val->guid.'"  class="js-img-viwer img-true-location" data-caption="" data-id="'.$attachment_id.'" >';
    52                     //=====================    PINTEREST lAYOUT   =============================
    53                     if ( $image_options_display_original == true and $image_options_thumbnail_options == false )
    54                     {
    55 
    56                       $html .= '<img class="image" style="height:100%;  width:100%;" src="'.$attachment_val->guid.'"  />';
    57 
    58                     }
    59                     elseif ( $image_options_thumbnail_options == true and $image_options_display_original == false )
    60                     {
    61                      
    62                       $html .= '<img class="image" style="height:100%;  width:100%;"  src="'.$image_attributes[0].'"  />';
    63 
    64                     }
    65                     else
    66                     {
    67 
    68                       $text =  '<p>Image Options => "Display Original Size Image" or "Display Thumnail Size" settings are turned on or off same time</p>';
    69 
    70                       print $text;
    71                      
    72                     }
    73 
    74 
    75                  
    76 
    77                     if ( ! empty( $attachment_id ) and true == $image_options_display_text )
    78                     {
    79 
    80 
    81                       $html .= '<div class="info" >';
    82                         if( ! empty( $attachment_val->post_title))
    83                         {
    84                           $html .= '<h5 class="text spartan-gallery-img-title" >'.$attachment_val->post_title.'</h5>';
    85                         }
    86                         if( ! empty( $attachment_val->post_content))  {
    87                           $html .= '<p class="text spartan-gallery-img-description" >'.$attachment_val->post_content.'</p>';
    88                         }
    89                        
    90                         if( ! empty( $attachment_val->guid ) ) {
    91                           $html .= ('<td colspan="3" style="background-color:#005673; text-align:right; padding: 4px 0px;">
    92                             <button class="spartan-gallery-img-button text" onclick="parent.open(\'' . $attachment_val->guid . '\')" >'.$attachment_val->post_title.'</button></td>');
    93                         }
    94                            
    95                       $html .= '</div>';
    96 
    97                     }
    98 
    99                 $html .= '</a>';
    100 
    101 
    102 
    103               if ( $image_options_display_original == true xor $image_options_thumbnail_options == true ) {
    104                 $html .= '</div>';
    105               }
    106 
    107 
     30            if ( $image_options_display_original == true xor $image_options_thumbnail_options == true ) {
     31                $brick_w_index = array_rand( $img_size, 1 );
     32                $brick_h_index = wp_rand( max( 0, $brick_w_index - 1 ), min( count( $img_size ) - 1, $brick_w_index + 1 ) );
     33                $html .= '<div class="freewall-brick-pinterest brick" data-width="' . $img_size[ $brick_w_index ] . '" data-height="' . $img_size[ $brick_h_index ] . '" data-delay="' . absint( $attachment_id ) . '">';
    10834            }
    10935
    110             if( true == $image_options_display_text ) {
    111               $html .= '<style>
    112                 .image
    113                 {
    114                   max-height: calc( 100% - '.$image_options_textbox_height_range.'% ) !important;
    115                 }
    116                 .info
    117                 {
    118                   max-height: calc( 100% - '.$image_options_textbox_height_range.'% ) !important;
    119                   background-color: '.$image_options_info_background_color.';
    120                   position: relative;
    121                   margin: 0px;
    122                   font-size: '.$image_options_container_font_size.'px !important ;
    123                 }
    124                
    125                 .info>p
    126                 {
    127                   font-size: '.$image_options_font_family['font-size'].';
    128                   color:      '.$image_options_font_family['color'].';
    129                   font-style:  '.$image_options_font_family['font-style'].';
    130                   font-family: '.$image_options_font_family['font-family'] .';
    131                   line-height:  '.$image_options_font_family['line-height'].';
    132                   font-weight: '.$image_options_font_family['font-weight'].';
    133                   text-align: '.$image_options_font_family['text-align'].';
    134                 }
    135                
    136                 .info>h5
    137                 {
    138                   font-size: '.$image_options_font_family['font-size'].';
    139                   color:      '.$image_options_font_family['color'].';
    140                   font-style:  '.$image_options_font_family['font-style'].';
    141                   font-family: '.$image_options_font_family['font-family'] .';
    142                   line-height:  '.$image_options_font_family['line-height'].';
    143                   font-weight: '.$image_options_font_family['font-weight'].';
    144                   text-align: '.$image_options_font_family['text-align'].';
    145                 }
     36            $html .= '<a href="' . esc_url( $attachment_val->guid ) . '" class="js-img-viwer img-true-location" data-caption="" data-id="' . absint( $attachment_id ) . '">';
    14637
    147                 .info>button
    148                 {
    149                   font-size: '.$image_options_font_family['font-size'].';
    150                   color:      '.$image_options_font_family['color'].';
    151                  
    152                 }
    153                 '.$image_options_add_extra_css.' 
    154               </style>';
    155              
     38            if ( $image_options_display_original == true and $image_options_thumbnail_options == false ) {
     39                $html .= '<img class="image" style="height:100%; width:100%; object-fit:cover; object-position:center;" loading="lazy" src="' . esc_url( $attachment_val->guid ) . '" />';
     40            } elseif ( $image_options_thumbnail_options == true and $image_options_display_original == false ) {
     41                $html .= '<img class="image" style="height:100%; width:100%; object-fit:cover; object-position:center;" loading="lazy" src="' . esc_url( $image_attributes[0] ) . '" />';
     42            } else {
     43                return '<p>' . esc_html__( 'Image Options: "Display Original" or "Display Thumbnail" must be enabled, but not both simultaneously.', 'spartan-gallery' ) . '</p>';
    15644            }
    157             $html .= '</div>';
    158           $html .= '</div>';
    15945
     46            $html .= '</a>';
    16047
    161           $html .= '
     48            if ( $image_options_display_original == true xor $image_options_thumbnail_options == true ) {
     49                $html .= '</div>';
     50            }
     51        }
     52
     53        $html .= '</div>';
     54        $html .= '</div>';
     55
     56        $html .= '
    16257            <script>
    16358                jQuery( document ).ready( function( $ ){
    164                 // Random width layout
    165                   var Imagewall = new Freewall("#freewall-pinterest");
    166                   Imagewall.reset({
    167                     selector: ".freewall-brick-pinterest",
    168                     animate: false,
    169                     cellW: 300,
    170                     cellH: "auto",
    171                     gutterY: '.$image_options_img_margin.',
    172                     gutterX: '.$image_options_img_margin.',
    173                     onResize: function() {
    174                       Imagewall.fitWidth();
    175                     }
    176                   });
    177                   $( document ).ready(function() {
    178                   Imagewall.fitWidth();
    179 
    180                   });
     59                    var Imagewall = new Freewall("#freewall-pinterest");
     60                    Imagewall.reset({
     61                        selector: ".freewall-brick-pinterest",
     62                        animate: false,
     63                        cellW: 300,
     64                        cellH: "auto",
     65                        gutterY: ' . $image_options_img_margin . ',
     66                        gutterX: ' . $image_options_img_margin . ',
     67                        onResize: function() {
     68                            Imagewall.fitWidth();
     69                        }
     70                    });
     71                    $( document ).ready(function() {
     72                        Imagewall.fitWidth();
     73                    });
    18174                });
    18275            </script>';
    18376
    184             return $html;
    185 
    186       }
    187 
    188 
    189 /*
    190       static function init_freewall_random_javascript()
    191       {
    192         $html .= '';
    193         $html .= '<script>';
    194           $html .= 'jQuery( document ).ready( function( $ ){';
    195             $html .= '$(".freewall-brick").each(function() {';
    196               $html .= 'var wall = new Freewall("#freewall");';
    197                 $html .= 'wall.reset({';
    198                   $html .= 'selector: "".brick",';
    199                   $html .= 'animate: true,';
    200                   $html .= 'cellW: 240,';
    201                   $html .= 'cellH: "auto",';
    202                   $html .= 'gutterY: 20,';
    203                   $html .= 'gutterX: 20,';
    204                   $html .= 'onResize: function() {';
    205                   $html .= 'wall.fitWidth();';
    206                   $html .= '}';
    207                   $html .= '});';
    208 
    209                   $html .= 'wall.container.find(".brick img").load(function() {';
    210                   $html .= 'wall.fitWidth();';
    211                 $html .= '});';
    212             $html .= '});';
    213           $html .= '});';
    214         $html .= '</script>';
    215 
    216         return  $html;
    217 
    218         //print_r( $script );
    219       }
    220 */
    221 
    222 
    223 
    224 
     77        return $html;
     78    }
    22579}
  • spartan-gallery/tags/1.4.0/public/html-cointainer-outputs/class-freewall-random-output.php

    r3204032 r3619020  
    11<?php
    22if ( ! defined( 'WPINC' ) ) {
    3 
    43    die;
    5 
    64}
    7 
    85
    96Class Freewall_Random_Container
    107{
    11 
    12 
    13       static function display_random_container( $attachments, $gallery_id  )
    14       {
    15 
     8    static function display_random_container( $attachments, $gallery_id )
     9    {
    1610        $CSSClass = new Spartan_Gallery_Generated_CSS_Output();
    1711
     12        $image_options_add_extra_css         = get_post_meta( $gallery_id, 'add_extra_css', true );
     13        $image_options_display_original      = get_post_meta( $gallery_id, 'display_original', true );
     14        $image_options_img_margin            = absint( get_post_meta( $gallery_id, 'img_margin', true ) );
     15        $image_options_thumbnail_options     = get_post_meta( $gallery_id, 'thumbnail_options', true );
     16        $image_options_thumbnail_size        = get_post_meta( $gallery_id, 'thumbnail_size', true );
     17        $safe_extra_css                      = wp_strip_all_tags( $image_options_add_extra_css );
     18
    1819        $html = '';
    19         $image_options_add_extra_css = get_post_meta( $gallery_id , 'add_extra_css', true );
    20         $html .= '<style>'.$image_options_add_extra_css.'</style>';
    21          
    22         $html .=  '  <div style="'.$CSSClass->output_php_Css($gallery_id).'" class="spartan-gallery-wrapper" >';
    23           $html .= '  <div id="freewall-random" class="masonary" >'; //data-fixSize="true"
    24           // Loop through them and output an image
    25             $img_size = array( '120', '160', '180', '240', '280', '320'   );
     20        $html .= '<style>' . $safe_extra_css . '</style>';
     21        $html .= '<div style="' . $CSSClass->output_php_Css( $gallery_id ) . '" class="spartan-gallery-wrapper">';
     22        $html .= '<div id="freewall-random" class="masonary">';
    2623
    27             foreach ( (array) $attachments as $attachment_id => $attachment_val ) {
     24        $img_size = array( '120', '160', '180', '240', '280', '320' );
    2825
    29                 $img_size = array( '120', '160', '180', '240', '280', '320'   );
    30                 //Settings variables for from database
    31                
    32                 $image_options_display_original = get_post_meta( $gallery_id , 'display_original', true ); // array
    33                 $image_options_img_margin = get_post_meta( $gallery_id , 'img_margin', true );
    34                 $image_options_thumbnail_options = get_post_meta( $gallery_id , 'thumbnail_options', true );
    35                 $image_options_textbox_height_range = get_post_meta( $gallery_id , 'textbox_height_range', true );
    36                 $image_options_display_text = get_post_meta( $gallery_id , 'display_text', true );
    37                 $image_options_info_background_color = get_post_meta( $gallery_id , 'info_background_color', true );
    38                 $image_options_container_font_size = get_post_meta( $gallery_id , 'container_font_size', true );
    39                 $image_options_thumbnail_size = get_post_meta( $gallery_id , 'thumbnail_size', true );
    40                 $image_options_font_family = get_post_meta( $gallery_id , 'font_family', true );
    41              
    42              
    43                 $image_attributes = wp_get_attachment_image_src( $attachment_val->ID , $image_options_thumbnail_size  );
     26        foreach ( (array) $attachments as $attachment_id => $attachment_val ) {
    4427
    45                 if ( $image_options_display_original == true xor $image_options_thumbnail_options == true ) {
    46                   $html .=  '<div  class="freewall-brick brick"  data-width="'.$img_size[array_rand( $img_size , 1 )].'" data-height="'.$img_size[array_rand( $img_size , 1 )].'" data-delay="'.$attachment_id.'"   >';
    47                 }
     28            $image_attributes = wp_get_attachment_image_src( $attachment_val->ID, $image_options_thumbnail_size );
    4829
    49                 $html .=  '<a  href="'.$attachment_val->guid.'"  class="js-img-viwer img-true-location" data-caption="" data-id="'.$attachment_id.'" >';
    50                     //=====================  Random width layout   =============================
    51                     if ( $image_options_display_original == true and $image_options_thumbnail_options == false ) {
     30            if ( $image_options_display_original == true xor $image_options_thumbnail_options == true ) {
     31                $html .= '<div class="freewall-brick brick" data-width="' . $img_size[ array_rand( $img_size, 1 ) ] . '" data-height="' . $img_size[ array_rand( $img_size, 1 ) ] . '" data-delay="' . absint( $attachment_id ) . '">';
     32            }
    5233
    53                       $html .= '<img class="image" style="height:240px;  width:100%;" src="'.$attachment_val->guid.'"  />';
     34            $html .= '<a href="' . esc_url( $attachment_val->guid ) . '" class="js-img-viwer img-true-location" data-caption="" data-id="' . absint( $attachment_id ) . '">';
    5435
    55                     } elseif ( $image_options_thumbnail_options == true and $image_options_display_original == false ) {
     36            if ( $image_options_display_original == true and $image_options_thumbnail_options == false ) {
     37                $html .= '<img class="image" style="height:240px; width:100%; object-fit:cover; object-position:center;" loading="lazy" src="' . esc_url( $attachment_val->guid ) . '" />';
     38            } elseif ( $image_options_thumbnail_options == true and $image_options_display_original == false ) {
     39                $html .= '<img style="height:240px; width:100%; object-fit:cover; object-position:center;" loading="lazy" src="' . esc_url( $image_attributes[0] ) . '" />';
     40            } else {
     41                return '<p>' . esc_html__( 'Image Options: "Display Original" or "Display Thumbnail" must be enabled, but not both simultaneously.', 'spartan-gallery' ) . '</p>';
     42            }
    5643
    57                       $html .= '<img style="height:240px;  width:100%;" src="'.$image_attributes[0].'"  />';
     44            $html .= '</a>';
    5845
    59                     } else
    60                     {
    61                       $text =  '<p>Image Options => "Display Original Size Image" or "Display Thumnail Size" settings are turned on or off same time</p>';
    62                       print $text;
    63                       //return;
    64                     }
     46            if ( $image_options_display_original == true xor $image_options_thumbnail_options == true ) {
     47                $html .= '</div>';
     48            }
     49        }
    6550
    66                    
     51        $html .= '</div>';
     52        $html .= '</div>';
    6753
    68                     if ( ! empty( $attachment_id ) and true == $image_options_display_text ) {
    69                       if( true == $image_options_display_text ) {
    70                           $html .= '<style>
    71                             .image
    72                             {
    73                               max-height: calc( 100% - '.$image_options_textbox_height_range.'% ) !important;
    74                             }
    75                             .info
    76                             {
    77                               max-height: calc( 100% - '.$image_options_textbox_height_range.'% ) !important;
    78                               background-color: '.$image_options_info_background_color.';
    79                               position: relative;
    80                               margin: 0px;
    81                               font-size: '.$image_options_container_font_size.'px !important ;
    82                             }
    83                            
    84                             .info>p
    85                             {
    86                               font-size: '.$image_options_font_family['font-size'].';
    87                               color:      '.$image_options_font_family['color'].';
    88                               font-style:  '.$image_options_font_family['font-style'].';
    89                               font-family: '.$image_options_font_family['font-family'] .';
    90                               line-height:  '.$image_options_font_family['line-height'].';
    91                               font-weight: '.$image_options_font_family['font-weight'].';
    92                               text-align: '.$image_options_font_family['text-align'].';
    93                             }
    94                            
    95                             .info>h5
    96                             {
    97                               font-size: '.$image_options_font_family['font-size'].';
    98                               color:      '.$image_options_font_family['color'].';
    99                               font-style:  '.$image_options_font_family['font-style'].';
    100                               font-family: '.$image_options_font_family['font-family'] .';
    101                               line-height:  '.$image_options_font_family['line-height'].';
    102                               font-weight: '.$image_options_font_family['font-weight'].';
    103                               text-align: '.$image_options_font_family['text-align'].';
    104                             }
    105 
    106                             .info>button
    107                             {
    108                               font-size: '.$image_options_font_family['font-size'].';
    109                               color:      '.$image_options_font_family['color'].';
    110                              
    111                             }
    112                             '.$image_options_add_extra_css.' 
    113                           </style>';
    114                          
    115                         }
    116 
    117                       $html .= '<div class="info" >';
    118                           if( ! empty( $attachment_val->post_title))
    119                           {
    120                             $html .= '<h5 class="text spartan-gallery-img-title" >'.$attachment_val->post_title.'</h5>';
    121                           }
    122                           if( ! empty( $attachment_val->post_content))  {
    123                             $html .= '<p class="text spartan-gallery-img-description" >'.$attachment_val->post_content.'</p>';
    124                           }
    125                          
    126                           if( ! empty( $attachment_val->guid ) ) {
    127                             $html .= ('<td colspan="3" style="background-color:#005673; text-align:right; padding: 4px 0px;">
    128                               <button class="spartan-gallery-img-button text" onclick="parent.open(\'' . $attachment_val->guid . '\')" >'.$attachment_val->post_title.'</button></td>');
    129                           }
    130                              
    131                        $html .= '</div>';
    132 
    133                       }
    134 
    135                 $html .= '</a>';
    136 
    137 
    138 
    139               if ( $image_options_display_original == true xor $image_options_thumbnail_options == true ) {
    140                 $html .= '</div>';
    141               }
    142 
    143 
    144 
    145             }
    146             $html .= '</div>';
    147           $html .= '</div>';
    148 
    149 
    150 
    151 
    152           $html .= '
    153               <script>
    154                   jQuery( document ).ready( function( $ ){
    155                   // Random width layout
     54        $html .= '
     55            <script>
     56                jQuery( document ).ready( function( $ ){
    15657                    var Imagewall = new Freewall("#freewall-random");
    15758                    Imagewall.reset({
    158                       selector: ".freewall-brick",
    159                       animate: true,
    160                       cellW: 200,
    161                       cellH: "auto",
    162                       gutterY: '.$image_options_img_margin.',
    163                       gutterX: '.$image_options_img_margin.',
    164                       onResize: function() {
    165                         Imagewall.fitWidth();
    166                       }
     59                        selector: ".freewall-brick",
     60                        animate: true,
     61                        cellW: 200,
     62                        cellH: "auto",
     63                        gutterY: ' . $image_options_img_margin . ',
     64                        gutterX: ' . $image_options_img_margin . ',
     65                        onResize: function() {
     66                            Imagewall.fitWidth();
     67                        }
    16768                    });
    16869                    $( document ).ready(function() {
    169                     Imagewall.fitWidth();
     70                        Imagewall.fitWidth();
     71                    });
     72                });
     73            </script>';
    17074
    171                     });
    172                   });
    173               </script>';
    174 
    175           return $html;
    176 
    177       }
    178 
    179 
    180 
    181 
     75        return $html;
     76    }
    18277}
  • spartan-gallery/tags/1.4.0/public/html-cointainer-outputs/class-hexagon-html-container.php

    r3204032 r3619020  
    11<?php
    22if ( ! defined( 'WPINC' ) ) {
    3 
    43    die;
    5 
    64}
    75
     6Class Spartan_Gallery_Hexagon
     7{
     8    static function hexagon_html_container( $attachments, $gallery_id )
     9    {
     10        $CSSClass = new Spartan_Gallery_Generated_CSS_Output();
    811
    9 Class Spartan_Gallery_Hexagon {
     12        $image_options_add_extra_css         = get_post_meta( $gallery_id, 'add_extra_css', true );
     13        $image_options_display_original      = get_post_meta( $gallery_id, 'display_original', true );
     14        $image_options_thumbnail_options     = get_post_meta( $gallery_id, 'thumbnail_options', true );
     15        $image_options_thumbnail_size        = get_post_meta( $gallery_id, 'thumbnail_size', true );
     16        $safe_extra_css                      = wp_strip_all_tags( $image_options_add_extra_css );
    1017
     18        $output = '';
     19        $output .= '<style>' . $safe_extra_css . '</style>';
     20        $output .= '<div style="' . $CSSClass->output_php_Css( $gallery_id ) . '" class="spartan-gallery-wrapper" style="position: relative; width: 100%;">';
     21        $output .= '<div class="masonary">';
     22        $output .= '<ul>';
    1123
    12   static function hexagon_html_container( $attachments, $gallery_id ) {
     24        foreach ( $attachments as $attachments_id => $attachments_val ) {
    1325
    14     $CSSClass = new Spartan_Gallery_Generated_CSS_Output();
    15     $output = '';
     26            $image_attributes = wp_get_attachment_image_src( $attachments_val->ID, $image_options_thumbnail_size );
    1627
    17     $image_options_add_extra_css = get_post_meta( $gallery_id , 'add_extra_css', true );
    18     $output  .= '<style>'.$image_options_add_extra_css.'</style>';
     28            $output .= '<li class="hex">';
     29            $output .= '<a class="js-img-viwer hexIn" data-caption="Title" data-id="' . absint( $attachments_id ) . '" href="' . esc_url( $attachments_val->guid ) . '">';
    1930
    20     $output .= '<div style="'.$CSSClass->output_php_Css($gallery_id).'" class="spartan-gallery-wrapper" style="position: relative;width: 100%;" >';
    21       $output .= '<div class="masonary" >';
    22         $output .= '<ul>';
    23           foreach ( $attachments as $attachments_id => $attachments_val ) {
    24                 $img_size = array( '120', '160', '180', '240', '280', '320'   );
    25                 //Settings variables for from database
    26                
    27                 $image_options_display_original = get_post_meta( $gallery_id , 'display_original', true ); // array
    28                 $image_options_img_margin = get_post_meta( $gallery_id , 'img_margin', true );
    29                 $image_options_thumbnail_options = get_post_meta( $gallery_id , 'thumbnail_options', true );
    30                 $image_options_textbox_height_range = get_post_meta( $gallery_id , 'textbox_height_range', true );
    31                 $image_options_display_text = get_post_meta( $gallery_id , 'display_text', true );
    32                 $image_options_info_background_color = get_post_meta( $gallery_id , 'info_background_color', true );
    33                 $image_options_container_font_size = get_post_meta( $gallery_id , 'container_font_size', true );
    34                 $image_options_thumbnail_size = get_post_meta( $gallery_id , 'thumbnail_size', true );
    35                 $image_options_font_family = get_post_meta( $gallery_id , 'font_family', true );
    36              
    37              
    38                 $image_attributes = wp_get_attachment_image_src( $attachments_val->ID , $image_options_thumbnail_size  );
    39                 //print_r($attachment_val);
     31            if ( $image_options_display_original == true and $image_options_thumbnail_options == false ) {
     32                $output .= '<img style="height:100%; width:100%; object-fit:cover; object-position:center;" loading="lazy" src="' . esc_url( $attachments_val->guid ) . '" />';
     33            } elseif ( $image_options_thumbnail_options == true and $image_options_display_original == false ) {
     34                $output .= '<img style="height:100%; width:100%; object-fit:cover; object-position:center;" loading="lazy" src="' . esc_url( $image_attributes[0] ) . '" />';
     35            } else {
     36                $output .= '<p>' . esc_html__( 'Image Options: "Display Original" or "Display Thumbnail" must be enabled, but not both simultaneously.', 'spartan-gallery' ) . '</p>';
     37            }
    4038
    41                 $output .=  '<li class="hex">';
    42                   $output .=    '<a class="js-img-viwer hexIn" data-caption="Title" data-id="'.$attachments_id.'" href="'.$attachments_val->guid.'">';
     39            $output .= '</a>';
     40            $output .= '</li>';
     41        }
    4342
    44                           if ( $image_options_display_original == true and $image_options_thumbnail_options == false ) {
     43        $output .= '</ul>';
     44        $output .= '</div>';
     45        $output .= '</div>';
    4546
    46                             $output .= '<img style="height:100%;  width:100%;" src="'.$attachments_val->guid.'"  />';
    47 
    48                           } elseif ( $image_options_thumbnail_options == true and $image_options_display_original == false ) {
    49 
    50                             $output .= '<img style="height:100%;  width:100%;" src="'.$image_attributes[0].'"  />';
    51 
    52                           } else
    53                           {
    54                             $output .=  '<p>Image Options => "Display Original Size Image" or "Display Thumnail Size" settings are turned on or off same time</p>';
    55 
    56                           }
    57 
    58 
    59                           if ( ! empty( $attachment_id ) and true == $image_options_display_text )
    60                           {
    61 
    62 
    63                             $html .= '<div class="info" >';
    64                               if( ! empty( $attachment_val->post_title))
    65                               {
    66                                 $html .= '<h5 class="text spartan-gallery-img-title" >'.$attachment_val->post_title.'</h5>';
    67                               }
    68                               if( ! empty( $attachment_val->post_content))  {
    69                                 $html .= '<p class="text spartan-gallery-img-description" >'.$attachment_val->post_content.'</p>';
    70                               }
    71                              
    72                               if( ! empty( $attachment_val->guid ) ) {
    73                                 $html .= ('<td colspan="3" style="background-color:#005673; text-align:right; padding: 4px 0px;">
    74                                   <button class="spartan-gallery-img-button text" onclick="parent.open(\'' . $attachment_val->guid . '\')" >'.$attachment_val->post_title.'</button></td>');
    75                               }
    76                                  
    77                             $html .= '</div>';
    78 
    79                           }
    80 
    81                       $output .= '</a>';
    82                   $output .= '</li>';
    83             }
    84           $output .= '</ul>';
    85         $output .= '</div>';
    86         $output .= '<script>';
    87         $output .= '';
    88 
    89 
    90         $output .= '</script>';
    91       $output .= '</div>';
    92 
    93     return $output;
    94 
     47        return $output;
    9548    }
    9649}
  • spartan-gallery/tags/1.4.0/public/popup.php

    r2145680 r3619020  
    1212        exit( 'Direct script access denied.' );
    1313}
    14 /**
    15 * Image gallerry button
    16 *
    17 * @since Spartan Gallery 1.0.2
    18 *
    19 * @param array  $urls           URLs to print for resource hints.
    20 * @param string $relation_type  The relation type the URLs are printed.
    21 * @return array $urls           URLs to print for resource hints.
    22 */
    2314
    2415function button_url_get_meta( $value ) {
    … …  
    3324}
    3425
    35 
    36 /**
    37 * Image gallerry button
    38 *
    39 * @since Spartan Gallery 1.0.2
    40 *
    41 * @param array  $urls           URLs to print for resource hints.
    42 * @param string $relation_type  The relation type the URLs are printed.
    43 * @return array $urls           URLs to print for resource hints.
    44 */
    45 
    4626function button_url_add_meta_box() {
    4727        add_meta_box(
    4828                'button_url-button-url',
    49                 __( 'b', 'button_url' ),
     29                __( 'Image Button Links', 'spartan-gallery' ),
    5030                'button_url_html',
    5131                'spartan_gallery_type',
    … …  
    5636add_action( 'add_meta_boxes', 'button_url_add_meta_box' );
    5737
    58 
    59 
    60 /**
    61 * Image gallerry button
    62 *
    63 * @since Spartan Gallery 1.0.2
    64 *
    65 * @param array  $urls           URLs to print for resource hints.
    66 * @param string $relation_type  The relation type the URLs are printed.
    67 * @return array $urls           URLs to print for resource hints.
    68 */
    69 function button_url_html( $post) {
     38function button_url_html( $post ) {
    7039        wp_nonce_field( '_button_url_nonce', 'button_url_nonce' );
    71 
    7240
    7341        $args = array(
    7442                'post_type'   => 'attachment',
    7543                'numberposts' => -1,
    76                 //'post_parent' => $page_id,
    7744                'post_status' => null,
    7845                'meta_query'  => array(
    … …  
    8249                        )
    8350                )
    84 
    8551        );
    8652
    8753        $attachments = get_posts( $args );
    8854
     55        foreach ( (array) $attachments as $attachment_id => $attachment_value ) {
     56                echo '<div class="popup" data-popup="popup-' . absint( $attachment_value->ID ) . '">';
     57                echo '<div class="popup-inner">';
    8958
    90   foreach ( (array) $attachments as $attachment_id => $attachment_value ) {
    91         $field = get_post_meta( $attachment_value->ID, 'button_url_buttontitle'.$attachment_value->ID, true );
    92         print_r( $field );
    93   echo '<div class="popup" data-popup="popup-'.$attachment_value->ID.'">';
    94   echo '<div class="popup-inner">';
    95         echo '<p>';
    96         echo  '<a><label for="button_url_buttonurl'.$attachment_value->ID.'">'._e( "Insert Button Url   ", "button_url" ).'   </label></a>';
    97         echo  '<a><input maxlength="160" type="text" name="button_url_buttonurl'.$attachment_value->ID.'" id="button_url_buttonurl'.$attachment_value->ID.'" value="'.button_url_get_meta( "button_url_buttonurl" .$attachment_value->ID ).'"></a>';
    98         echo '  </p>';
     59                echo '<p>';
     60                echo '<a><label for="button_url_buttonurl' . absint( $attachment_value->ID ) . '">' . esc_html__( 'Insert Button Url', 'spartan-gallery' ) . '</label></a>';
     61                echo '<a><input maxlength="160" type="text" name="button_url_buttonurl' . absint( $attachment_value->ID ) . '" id="button_url_buttonurl' . absint( $attachment_value->ID ) . '" value="' . esc_attr( button_url_get_meta( 'button_url_buttonurl' . $attachment_value->ID ) ) . '"></a>';
     62                echo '</p>';
    9963
    100         echo '<p>';
    101         echo  '<a><label for="button_url_buttonurl'.$attachment_value->ID.'">'._e( "Insert Button Title   ", "button_url" ).'   </label></a>';
    102         echo  '<a><input maxlength="160" type="text" name="button_url_buttontitle'.$attachment_value->ID.'" id="button_url_buttontitle'.$attachment_value->ID.'" value="'.button_url_get_meta( "button_url_buttontitle" .$attachment_value->ID ).'"></a>';
    103         echo '  </p>';
     64                echo '<p>';
     65                echo '<a><label for="button_url_buttontitle' . absint( $attachment_value->ID ) . '">' . esc_html__( 'Insert Button Title', 'spartan-gallery' ) . '</label></a>';
     66                echo '<a><input maxlength="160" type="text" name="button_url_buttontitle' . absint( $attachment_value->ID ) . '" id="button_url_buttontitle' . absint( $attachment_value->ID ) . '" value="' . esc_attr( button_url_get_meta( 'button_url_buttontitle' . $attachment_value->ID ) ) . '"></a>';
     67                echo '</p>';
    10468
    105         echo '<p>';
    106         echo  '<a><label for="imgtitle'.$attachment_value->ID.'">'._e( "Insert Image Title   ", "button_url" ).'   </label></a>';
    107         echo  '<a><input maxlength="160" type="text" name="imgtitle'.$attachment_value->ID.'" id="imgtitle'.$attachment_value->ID.'" value="'.button_url_get_meta( "imgtitle" .$attachment_value->ID ).'"></a>';
    108         echo '  </p>';
    109         echo '<p>';
     69                echo '<p>';
     70                echo '<a><label for="imgtitle' . absint( $attachment_value->ID ) . '">' . esc_html__( 'Insert Image Title', 'spartan-gallery' ) . '</label></a>';
     71                echo '<a><input maxlength="160" type="text" name="imgtitle' . absint( $attachment_value->ID ) . '" id="imgtitle' . absint( $attachment_value->ID ) . '" value="' . esc_attr( button_url_get_meta( 'imgtitle' . $attachment_value->ID ) ) . '"></a>';
     72                echo '</p>';
    11073
    111         echo  '<a><label for="imgdescription'.$attachment_value->ID.'">'._e( "Insert Image Description   ", "button_url" ).'   </label></a>';
    112         echo  '<a><input maxlength="160" type="text" name="imgdescription'.$attachment_value->ID.'" id="imgdescription'.$attachment_value->ID.'" value="'.button_url_get_meta( "imgdescription" .$attachment_value->ID ).'"></a>';
    113         echo '  </p>';
    114   echo '<p><a id="close-popup" data-popup-close="popup-'.$attachment_value->ID.'" href="#">Close</a></p>';
    115   echo ' <a id="close-popup" class="popup-close" data-popup-close="popup-'.$attachment_value->ID.'" href="#">x</a>';
    116   echo '</div>';
    117   echo '</div>';
     74                echo '<p>';
     75                echo '<a><label for="imgdescription' . absint( $attachment_value->ID ) . '">' . esc_html__( 'Insert Image Description', 'spartan-gallery' ) . '</label></a>';
     76                echo '<a><input maxlength="160" type="text" name="imgdescription' . absint( $attachment_value->ID ) . '" id="imgdescription' . absint( $attachment_value->ID ) . '" value="' . esc_attr( button_url_get_meta( 'imgdescription' . $attachment_value->ID ) ) . '"></a>';
     77                echo '</p>';
    11878
     79                echo '<p><a id="close-popup" data-popup-close="popup-' . absint( $attachment_value->ID ) . '" href="#">' . esc_html__( 'Close', 'spartan-gallery' ) . '</a></p>';
     80                echo '<a id="close-popup" class="popup-close" data-popup-close="popup-' . absint( $attachment_value->ID ) . '" href="#">x</a>';
     81                echo '</div>';
     82                echo '</div>';
     83        }
    11984}
    12085
    121 }
    122 
    123 
    124 
    125 /**
    126 * Image gallerry button
    127 *
    128 * @since Spartan Gallery 1.0.2
    129 *
    130 * @param array  $urls           URLs to print for resource hints.
    131 * @param string $relation_type  The relation type the URLs are printed.
    132 * @return array $urls           URLs to print for resource hints.
    133 */
    13486function button_url_save( $post_id ) {
    13587        if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return;
    … …  
    13789        if ( ! current_user_can( 'edit_post', $post_id ) ) return;
    13890
    139                                 $args = array(
    140                                         'post_type'   => 'attachment',
    141                                         'numberposts' => -1,
    142                                         //'post_parent' => $page_id,
    143                                         'post_status' => null,
    144                                         'meta_query'  => array(
    145                                                 array(
    146                                                         'key'     => 'spartan_gallery',
    147                                                         'compare' => '=',
    148                                                 )
    149                                         )
     91        $args = array(
     92                'post_type'   => 'attachment',
     93                'numberposts' => -1,
     94                'post_status' => null,
     95                'meta_query'  => array(
     96                        array(
     97                                'key'     => 'spartan_gallery',
     98                                'compare' => '=',
     99                        )
     100                )
     101        );
    150102
    151                                 );
     103        $attachments = get_posts( $args );
    152104
    153                                 $attachments = get_posts( $args );
    154         foreach ( (array) $attachments as $attachments_id => $attachment_value ) {
     105        foreach ( (array) $attachments as $attachments_id => $attachment_value ) {
     106                $id = $attachment_value->ID;
    155107
    156                 if ( sanitize_text_field(  isset($_POST['button_url_buttonurl'.$attachment_value->ID.'']) ) )
    157                         update_post_meta( $post_id, 'button_url_buttonurl'.$attachment_value->ID.'', $_POST['button_url_buttonurl'.$attachment_value->ID.''] );
     108                if ( isset( $_POST[ 'button_url_buttonurl' . $id ] ) ) {
     109                        update_post_meta( $post_id, 'button_url_buttonurl' . $id, sanitize_text_field( wp_unslash( $_POST[ 'button_url_buttonurl' . $id ] ) ) );
     110                }
    158111
    159                 if ( sanitize_text_field( isset($_POST['button_url_buttontitle'.$attachment_value->ID.''] ) ) )
    160                         update_post_meta( $post_id, 'button_url_buttontitle'.$attachment_value->ID.'', $_POST['button_url_buttontitle'.$attachment_value->ID.''] );
     112                if ( isset( $_POST[ 'button_url_buttontitle' . $id ] ) ) {
     113                        update_post_meta( $post_id, 'button_url_buttontitle' . $id, sanitize_text_field( wp_unslash( $_POST[ 'button_url_buttontitle' . $id ] ) ) );
     114                }
    161115
    162                 if ( sanitize_text_field( isset($_POST['imgtitle'.$attachment_value->ID.'']) ) )
    163                         update_post_meta( $post_id, 'imgtitle'.$attachment_value->ID.'', $_POST['imgtitle'.$attachment_value->ID.''] );
     116                if ( isset( $_POST[ 'imgtitle' . $id ] ) ) {
     117                        update_post_meta( $post_id, 'imgtitle' . $id, sanitize_text_field( wp_unslash( $_POST[ 'imgtitle' . $id ] ) ) );
     118                }
    164119
    165                 if ( sanitize_text_field(isset($_POST['imgdescription'.$attachment_value->ID.'']) ) )
    166                         update_post_meta( $post_id, 'imgdescription'.$attachment_value->ID.'', $_POST['imgdescription'.$attachment_value->ID.''] );
    167               }
    168 
     120                if ( isset( $_POST[ 'imgdescription' . $id ] ) ) {
     121                        update_post_meta( $post_id, 'imgdescription' . $id, sanitize_text_field( wp_unslash( $_POST[ 'imgdescription' . $id ] ) ) );
     122                }
     123        }
    169124}
    170125add_action( 'save_post', 'button_url_save' );
  • spartan-gallery/tags/1.4.0/public/spartan-gallery-styles.php

    r3204032 r3619020  
    1313}
    1414
    15 /**
    16 * Image styles
    17 *
    18 * @since Spartan Gallery 1.0.2
    19 *
    20 * @param array  $urls           URLs to print for resource hints.
    21 * @param string $relation_type  The relation type the URLs are printed.
    22 * @return array $urls           URLs to print for resource hints.
    23 */
    2415Class Spartan_Gallery_Generated_CSS_Output
    2516{
     17    static function output_php_Css( $gallery_id )
     18    {
     19        $image_options_container_settings_on_off   = get_post_meta( $gallery_id, 'container_settings_on_off', true );
     20        $image_options_container_height_width_range = get_post_meta( $gallery_id, 'container_height_width_range', true );
     21        $image_options_container_background_color  = get_post_meta( $gallery_id, 'container_background_color', true );
     22        $image_options_container_border            = get_post_meta( $gallery_id, 'container_border', true );
    2623
     24        $css = '';
    2725
    28       static function output_php_Css( $gallery_id  )
    29       {
    30  
    31                                         $image_options_container_settings_on_off = get_post_meta( $gallery_id , 'container_settings_on_off', true );
    32                                         $image_options_container_height_width_range = get_post_meta( $gallery_id , 'container_height_width_range', true );
    33                                         $image_options_container_background_color = get_post_meta( $gallery_id , 'container_background_color', true );
    34                                         $image_options_container_border = get_post_meta( $gallery_id , 'container_border', true );
     26        if ( $image_options_container_settings_on_off == true ) {
     27            $css .= '
     28                border-top: '    . esc_attr( $image_options_container_border['border-top'] )    . ';
     29                border-right: '  . esc_attr( $image_options_container_border['border-right'] )  . ';
     30                border-bottom: ' . esc_attr( $image_options_container_border['border-bottom'] ) . ';
     31                border-left: '   . esc_attr( $image_options_container_border['border-left'] )   . ';
     32                border-style: '  . esc_attr( $image_options_container_border['border-style'] )  . ';
     33                border-color: '  . esc_attr( $image_options_container_border['border-color'] )  . ';
     34                background-color: ' . esc_attr( $image_options_container_background_color ) . ';
     35                height: '        . esc_attr( $image_options_container_height_width_range['height'] ) . ';
     36                width: '         . esc_attr( $image_options_container_height_width_range['width'] )  . ';
     37            ';
     38        }
    3539
    36                                        
    37                                         $css = '';
    38                                         //$css .= '<style>';
    39                                                 if ( $image_options_container_settings_on_off  == true ) {
    40                                                 $css .= '
    41                                                                
    42                                                                         border-top: '.$image_options_container_border['border-top'].' ; 
    43                                                                         border-right: '.$image_options_container_border['border-right'].';
    44                                                                         border-bottom: '.$image_options_container_border['border-bottom'].';
    45                                                                         border-left: '.$image_options_container_border['border-left'].';
    46                                                                         border-style: '.$image_options_container_border['border-style'].';
    47                                                                         border-color: '.$image_options_container_border['border-color'].';
    48                                                                         background-color: '.$image_options_container_background_color.';
    49                                                                         height: '.$image_options_container_height_width_range['height'].';
    50                                                                         width: '.$image_options_container_height_width_range['width'].';
    51                                                                 ';
    52                                                 }
    53                                                
    54 
    55                                         //$css .= '</style>';
    56 
    57                                         return $css;
    58 
    59                         }
    60 
    61 
     40        return $css;
     41    }
    6242}
  • spartan-gallery/tags/1.4.0/readme.txt

    r3204032 r3619020  
    22
    33Contributors:       Freelancer Martin
    4 Tags:               gallery, portfolio, simple portfolio gallery, photo gallery, art gallery, photographer gallery,
     4Tags:               gallery, portfolio, photo gallery, gutenberg, responsive
    55Requires at least: 4.6
    6 Tested up to: 6.7
    7 Requires PHP: 8.3
    8 Stable tag:         1.3.0
     6Tested up to: 7.0
     7Requires PHP: 7.4
     8Stable tag:         1.4.0
    99License:            GPLv2 or later
    10 License URI:        [http://www.gnu.org/licenses/gpl-2.0.html](http://www.gnu.org/licenses/gpl-2.0.html)
     10License URI:        http://www.gnu.org/licenses/gpl-2.0.html
    1111
    1212== Description ==
    1313
    14 Spartan Gallery allows you to create gallery very very easily. Spartan Gallery is a responsive and multipurpose portfolio gallery plugin. You can use it for: agency, personal portfolio, architect agency, architecture portfolio, photography studios, creative agency, design studios, painter portfolio, model agency, escort agency, products showcase, artworks, art, artist portfolio, web design works, illustrators, projects, blog, freelance designer etc.
    15 This plugin is truly best for individual who want to deal with numerous of photos. This plugin is also designed with stunning modern style. More over, with plugin option panel. You can change almost everything easily via admin panel. Spartan Gallery is responsive and supports all devices, user-friendly and fine-looking. It is very nice with its clean and professional look.
     14Spartan Gallery is a responsive, multipurpose portfolio gallery plugin for WordPress. It works well for agencies, personal portfolios, architecture and photography studios, product showcases, artist portfolios, and blogs.
    1615
    17 Now added Redux Framework, added gutenberg block to add gallerys on site, fixed some issuses with plugin
     16Six layout styles are included: Freewall Chaotic, Random, Fixed, Pinterest, Hexagon, and 3D Slider. Each gallery has its own options panel to control image size, thumbnail behavior, container styling, and custom CSS, plus a Gutenberg block for adding galleries anywhere in the block editor.
    1817
    1918= Visit Example Site  =
    … …  
    4443If installing the plugin from wordpress.org:
    4544
    46 1 . Upload or Intall the entire /Spartan Gallery directory to the /wp-content/plugins/ directory.
    47 2 . Upload the entire plugin directory to the /wp-content/plugins/ directory.
    48 3 . Activate Spartan Gallery through the 'Plugins' menu in WordPress.
    49 4 . Go to Create New Gallery
    50 5 . Upload Images -> choose layouts options -> select image settings
    51 6 . Copy and Paste shortcode, where would you like see gallery
    52 7 . Profit.
     451. Upload or install the entire /spartan-gallery directory to the /wp-content/plugins/ directory, or install directly through the 'Plugins' screen in WordPress.
     462. Activate Spartan Gallery through the 'Plugins' menu in WordPress.
     473. Go to Spartan Gallery > Add New to create a gallery.
     484. Upload images, choose a layout, and select image settings.
     495. Copy the shortcode (or use the Gutenberg block) wherever you'd like the gallery to appear.
    5350
    5451
    … …  
    7471== Changelog ==
    7572
     73= 1.4.0 =
     74* Removed the Redux Framework dependency; the gallery options panel is now a native WordPress metabox (no third-party plugin required).
     75* Fixed images being stretched/distorted in all six layouts.
     76* Fixed several settings (thumbnail size, adjustable image, container settings) not saving correctly when turned off.
     77* Fixed slider controls not being usable in the options panel.
     78* Removed the "display text under image" caption feature.
     79* Various security hardening and bug fixes.
     80
    7681= 1.3.0 =
    77 * Version 1.0.0 - First Stable Release
    78 * Version 1.2.0 - Upate user interface, new core and class system, new proper class system for plugin
    79 * Version 1.3.0 - Now using redux framework, added gutenbergblock, changed UI, proper testing, made sure everylaout is working, fixed UI
     82* Added Gutenberg block support.
     83* UI improvements and layout fixes.
     84
     85= 1.2.0 =
     86* Updated user interface; new core class system for the plugin.
     87
     88= 1.0.0 =
     89* First stable release.
     90
     91== Upgrade Notice ==
     92
     93= 1.4.0 =
     94Removes the Redux Framework dependency in favor of a built-in options panel — your existing gallery settings carry over automatically. If Redux Framework was installed only for this plugin, it can now be deactivated.
  • spartan-gallery/tags/1.4.0/spartan-gallery.php

    r3204032 r3619020  
    1515 * @wordpress-plugin
    1616 * Plugin Name:       Spartan Gallery
    17  * Plugin URI:        spartan-gallery.developerforwebsites.com
    18  * Description:       This is a short description of what the plugin does. It's displayed in the WordPress admin area.
    19  * Version:           1.0.0
     17 * Description:       A responsive, multipurpose gallery plugin with six layout styles (Freewall Chaotic, Random, Fixed, Pinterest, Hexagon, and 3D Slider), a Gutenberg block, and per-gallery image/container styling options.
     18 * Version:           1.4.0
    2019 * Author:            Freelancer Martin
    21  * Author URI:        developerforwebsites@gmail.com
     20 * Author URI:        https://freelancermartin.com
    2221 * License:           GPL-2.0+
    2322 * License URI:       http://www.gnu.org/licenses/gpl-2.0.txt
    … …  
    3635 * Rename this for your plugin and update it as you release new versions.
    3736 */
    38 define( 'PLUGIN_NAME_VERSION', '1.2.1' );
     37define( 'PLUGIN_NAME_VERSION', '1.4.0' );
    3938
    4039
    … …  
    8180
    8281
    83 //require_once plugin_dir_path( __FILE__ ) . 'admin/exopite-simple-options/exopite-simple-options-framework-class.php';
    84 
    8582/**
    8683 * The code that runs during plugin deactivation.
  • spartan-gallery/trunk/admin/class-add-gallery-gutenberg-block.php

    r3204032 r3619020  
    11<?php
     2
     3if ( ! defined( 'WPINC' ) ) {
     4        die;
     5}
    26
    37// Register the block and its settings
    … …  
    4549                        $my_meta_options = get_post_meta( $gallery_id , 'image_layout_select', true ); // array
    4650
    47                         $get_all_post_attachements = get_post_meta( $gallery_id , 'spartan_gallery_uploaded_images', true );
    48            
    49                        
     51                        $get_all_post_attachements = get_post_meta( $gallery_id , 'spartan_gallery_uploaded_images', true );
    5052
    5153                        // Loop through each post ID
    52                         foreach (explode(',',$get_all_post_attachements) as $post_id) {
    53                                 // Retrieve the post object by ID
    54                                 $post = get_post($post_id);
     54                        $post_guids = array();
     55                        if ( ! empty( $get_all_post_attachements ) ) {
     56                                foreach ( explode( ',', $get_all_post_attachements ) as $post_id ) {
     57                                        // Retrieve the post object by ID
     58                                        $post = get_post( absint( $post_id ) );
    5559
    56                                 // Check if the post exists
    57                                 if ($post) {
    58                                         // Get the GUID of the post and push it into the array
    59                                         $post_guids[] = $post;
     60                                        // Check if the post exists
     61                                        if ( $post ) {
     62                                                // Get the GUID of the post and push it into the array
     63                                                $post_guids[] = $post;
     64                                        }
    6065                                }
     66                        }
     67
     68                        if ( empty( $post_guids ) ) {
     69                                return '<p>No images found in this gallery.</p>';
    6170                        }
    6271
  • spartan-gallery/trunk/admin/class-spartan-gallery-admin.php

    r3204032 r3619020  
    6060                $this->plugin_name = $plugin_name;
    6161                $this->version = $version;
    62                 // Hook into plugin activation
    63                 add_action( 'admin_init', array($this,'spartan_gallery_check_and_install_redux' ));
    64 
    65                 add_action( 'plugins_loaded', array($this,'spartan_gallery_load_redux' ));
    66                
    6762
    6863        }
    … …  
    121116
    122117
    123         public function spartan_gallery_check_and_install_redux()
    124         {
    125                 // Ensure WordPress is loaded
    126                 if ( ! function_exists( 'wp_generate_password' ) ) {
    127                         error_log( 'WordPress not fully loaded. Aborting Redux installation.' );
    128                         return;
    129                 }
    130        
    131                 if ( ! class_exists( 'ReduxFramework' ) ) {
    132                         require_once ABSPATH . 'wp-admin/includes/plugin-install.php';
    133                         require_once ABSPATH . 'wp-admin/includes/file.php';
    134                         require_once ABSPATH . 'wp-admin/includes/misc.php';
    135                         require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
    136        
    137                         // Get plugin information for Redux Framework
    138                         $plugin_slug = 'redux-framework';
    139                         $plugin_info = plugins_api( 'plugin_information', array( 'slug' => $plugin_slug ) );
    140        
    141                         if ( is_wp_error( $plugin_info ) ) {
    142                                 error_log( 'Error fetching Redux Framework plugin info: ' . $plugin_info->get_error_message() );
    143                                 return;
    144                         }
    145        
    146                         $download_link = $plugin_info->download_link;
    147        
    148                         $upgrader = new Plugin_Upgrader();
    149                         $installed = $upgrader->install( $download_link );
    150        
    151                         if ( $installed ) {
    152                                 $plugin_file = WP_PLUGIN_DIR . "/$plugin_slug/$plugin_slug.php";
    153                                 if ( file_exists( $plugin_file ) ) {
    154                                         activate_plugin( $plugin_file );
    155                                 } else {
    156                                         error_log( 'Redux Framework installation failed: Plugin file not found.' );
    157                                 }
    158                         } else {
    159                                 error_log( 'Redux Framework installation failed: Unable to download or install the plugin.' );
    160                         }
    161                 }
    162         }
    163 
    164         // Load Redux Framework after all plugins are loaded
    165         public function spartan_gallery_load_redux() {
    166                 // Check if Redux Framework is installed and active
    167                 if ( class_exists( 'ReduxFramework' ) )
    168                 {
    169                        
    170                         // Path to Redux plugin's main file
    171                         $redux_plugin_file = WP_PLUGIN_DIR . '/redux-framework/redux-framework.php';
    172                        
    173                         if ( file_exists( $redux_plugin_file ) ) {
    174                                 include_once $redux_plugin_file;
    175        
    176                                 // Now include your Redux configuration file
    177                                 //require_once plugin_dir_path( __FILE__ ) . 'redux-config.php';
    178                                 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-spartan-gallery-options.php';
    179                         } else {
    180                                 error_log( 'Redux Framework plugin is not installed or not found in the plugins directory.' );
    181                         }
    182                 }
    183         }
    184        
    185        
    186        
    187 
    188118}
  • spartan-gallery/trunk/admin/class-spartan-gallery-metaboxes.php

    r2145680 r3619020  
    77*/
    88if ( ! defined( 'WPINC' ) ) {
    9 
    109    die;
    11 
    1210}
    13 
    1411
    1512function spartan_gallery_meta_box_add()
    … …  
    1714    add_meta_box( 'new-spartan-gallery-box', 'Shortcode', 'spartan_gallery_paybal_meta_box_cb', 'spartan_gallery_type', 'normal', 'low' );
    1815}
    19 
    2016add_action( 'add_meta_boxes', 'spartan_gallery_meta_box_add' );
    2117
    2218function spartan_gallery_paybal_meta_box_cb()
    2319{
    24 
     20    $gallery_id = absint( get_the_ID() );
    2521?>
    2622
    27 
    28   <div >
    29 
    30 
     23  <div>
    3124      <div class="postbox">
    32 
    33           <h3 style="border-bottom: 1px solid #EEE;background: #f7f7f7;"><span class="tcode"><?php _e("Shortcode", "easy-textillate"); ?></span></h3>
     25          <h3 style="border-bottom: 1px solid #EEE;background: #f7f7f7;"><span class="tcode"><?php esc_html_e( 'Shortcode', 'spartan-gallery' ); ?></span></h3>
    3426          <div class="inside" style="padding-bottom:20px;display: block;">
    35 
    36           <table width="100%">
    37           <tr><td>
    38 
    39            <p><code style="color:#A71D5D;" >[spartan_gallery  id='<?php print_r(get_the_ID()); ?>']</code></p>
    40 
    41           </td>
    42           <td width="50px" style="align:right;">
    43 
    44            </td></tr>
    45            </table>
    46 
     27              <table width="100%">
     28              <tr><td>
     29                  <p><code style="color:#A71D5D;">[spartan_gallery id='<?php echo esc_html( $gallery_id ); ?>']</code></p>
     30              </td></tr>
     31              </table>
    4732          </div>
    4833      </div>
    4934
    5035      <div class="postbox">
    51           <h3 style="border-bottom: 1px solid #EEE;background: #f7f7f7;"><span class="tcode"><?php _e("PHP code", "easy-textillate"); ?></span></h3>
     36          <h3 style="border-bottom: 1px solid #EEE;background: #f7f7f7;"><span class="tcode"><?php esc_html_e( 'PHP code', 'spartan-gallery' ); ?></span></h3>
    5237          <div class="inside" style="padding-bottom:20px;display: block;">
    53 
    54           <table width="100%">
    55           <tr><td>
    56             <p><code style="color:#A71D5D;" >echo do_shortcode("[spartan_gallery id='<?php print_r(get_the_ID()); ?>']");</code></p>
    57            </td>
    58           <td width="50px" style="align:right;">
    59 
    60 
    61 
    62            </td></tr>
    63            </table>
    64 
     38              <table width="100%">
     39              <tr><td>
     40                  <p><code style="color:#A71D5D;">echo do_shortcode("[spartan_gallery id='<?php echo esc_html( $gallery_id ); ?>']");</code></p>
     41              </td></tr>
     42              </table>
    6543          </div>
    6644      </div>
    6745
    6846      <div class="postbox">
    69           <h3 style="border-bottom: 1px solid #EEE;background: #f7f7f7;"><span class="tcode"><?php _e("Do you like this plugin ?", "easy-textillate"); ?></span></h3>
     47          <h3 style="border-bottom: 1px solid #EEE;background: #f7f7f7;"><span class="tcode"><?php esc_html_e( 'Do you like this plugin?', 'spartan-gallery' ); ?></span></h3>
    7048          <div class="inside" style="display: block;">
    71               <img src="<?php echo plugin_dir_url( '' ) . 'spartan-gallery/admin/img/index.jpeg'; ?>" title="<?php _e("buy me a coffee", "easy-textillate"); ?>" style=" margin: 5px; float:left;" />
    72 
    73               <p><?php _e("Hi! I'm <strong>Freelancer Martin</strong>, developer of this plugin.", "easy-textillate"); ?></p>
    74               <p><?php _e("I've been spending many hours to develop this plugin.", "easy-textillate"); ?> <br />
    75               <?php _e("If you like and use this plugin and would like to see future development, you can <strong>buy me a cup of coffee</strong>.", "easy-textillate"); ?></p>
     49              <img src="<?php echo esc_url( plugin_dir_url( '' ) . 'spartan-gallery/admin/img/index.jpeg' ); ?>" title="<?php esc_attr_e( 'buy me a coffee', 'spartan-gallery' ); ?>" style="margin: 5px; float:left;" />
     50              <p><?php esc_html_e( "Hi! I'm Freelancer Martin, developer of this plugin.", 'spartan-gallery' ); ?></p>
     51              <p><?php esc_html_e( "I've been spending many hours to develop this plugin.", 'spartan-gallery' ); ?><br />
     52              <?php esc_html_e( 'If you like and use this plugin and would like to see future development, you can buy me a cup of coffee.', 'spartan-gallery' ); ?></p>
    7653              <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=CVJ7GE7QM5F3N" target="_blank" rel="nofollow"><img src="https://www.paypal.com/en_US/i/btn/x-click-but21.gif" alt="" /></a>
    77 
    78 
    7954              <div style="clear:both;"></div>
    80        </div>
    81 
     55          </div>
     56      </div>
    8257  </div>
    8358
    84 
    8559<?php
    86 
    8760}
  • spartan-gallery/trunk/admin/class-spartan-gallery-options.php

    r3204032 r3619020  
    11<?php
    2 if ( ! class_exists( 'Redux' ) ) {
    3     return;
     2/**
     3 * Spartan Gallery Options metabox.
     4 *
     5 * Native WordPress replacement for the previous Redux Framework options panel.
     6 * Renders the same sections/fields and writes to the exact same post_meta keys
     7 * the rest of the plugin (public/html-cointainer-outputs/*, spartan-gallery-styles.php)
     8 * already reads, so no other file needed to change.
     9 *
     10 * @package Spartan_Gallery
     11 * @subpackage Spartan_Gallery/admin
     12 */
     13if ( ! defined( 'WPINC' ) ) {
     14        die;
    415}
    516
    6 $opt_name = 'spartan_gallery_options';
    7 /*
    8 $args = array(
    9     'opt_name'             => $opt_name,
    10     'display_name'         => 'My Plugin Options',
    11     'menu_title'           => 'My Plugin Settings',
    12     'page_title'           => 'My Plugin Options',
    13     'admin_bar'            => true,
    14     'menu_type'            => 'menu',
    15     'allow_sub_menu'       => true,
    16     'page_parent_post_type' => 'spartan_gallery_type',
    17     'customizer'           => true,
    18 );
    19 */
    20 Redux::setArgs( $opt_name/*, $args*/ );
    21 
    22 
    23 
    24 // Example Section
    25 Redux::setSection( $opt_name, array(
    26     'title'  => 'General Settings',
    27     //'id'     => 'general',
    28     'desc'   => 'Basic settings for your plugin.',
    29    
    30 ) );
    31 
    32 // Change this variable to the opt_name of YOUR project.
    33 //$opt_name = 'your_opt_name';
    34 /*
    35 // Standard metabox.
    36 Redux_Metaboxes::set_box(
    37         $opt_name,
    38         array(
    39                 'id'         => 'opt-metaboxes',
    40                 'title'      => esc_html__( 'Metabox Options', 'your-textdomain-here' ),
    41                 'post_types' => array( 'spartan_gallery_type' ),
    42                 'position'   => 'normal', // normal, advanced, side.
    43                 'priority'   => 'high',   // high, core, default, low.
    44                 'sections'   => array(
     17class Spartan_Gallery_Options {
     18
     19        const POST_TYPE = 'spartan_gallery_type';
     20        const NONCE_ACTION = 'spartan_gallery_options_save';
     21        const NONCE_NAME   = 'spartan_gallery_options_nonce';
     22
     23        public static function init() {
     24                add_action( 'add_meta_boxes', array( __CLASS__, 'add_meta_box' ) );
     25                add_action( 'save_post', array( __CLASS__, 'save' ) );
     26                add_action( 'admin_enqueue_scripts', array( __CLASS__, 'enqueue_assets' ) );
     27        }
     28
     29        public static function add_meta_box() {
     30                add_meta_box(
     31                        'spartan-gallery-options',
     32                        esc_html__( 'Spartan Gallery Options', 'spartan-gallery' ),
     33                        array( __CLASS__, 'render' ),
     34                        self::POST_TYPE,
     35                        'normal',
     36                        'high'
     37                );
     38        }
     39
     40        public static function enqueue_assets( $hook ) {
     41                if ( ! in_array( $hook, array( 'post.php', 'post-new.php' ), true ) ) {
     42                        return;
     43                }
     44
     45                $screen = get_current_screen();
     46                if ( ! $screen || self::POST_TYPE !== $screen->post_type ) {
     47                        return;
     48                }
     49
     50                wp_enqueue_style( 'wp-color-picker' );
     51                wp_enqueue_style(
     52                        'spartan-gallery-options',
     53                        plugin_dir_url( __FILE__ ) . 'css/spartan-gallery-options.css',
     54                        array( 'wp-color-picker' ),
     55                        PLUGIN_NAME_VERSION
     56                );
     57
     58                wp_enqueue_media();
     59                wp_enqueue_script( 'jquery-ui-slider' );
     60                wp_enqueue_script( 'jquery-ui-spinner' );
     61                wp_enqueue_script( 'wp-color-picker' );
     62
     63                $cm_settings = wp_enqueue_code_editor( array( 'type' => 'text/css' ) );
     64
     65                wp_enqueue_script(
     66                        'spartan-gallery-options',
     67                        plugin_dir_url( __FILE__ ) . 'js/spartan-gallery-options.js',
     68                        array( 'jquery', 'jquery-ui-slider', 'jquery-ui-spinner', 'wp-color-picker', 'media-editor' ),
     69                        PLUGIN_NAME_VERSION,
     70                        true
     71                );
     72
     73                wp_localize_script(
     74                        'spartan-gallery-options',
     75                        'sgOptionsData',
    4576                        array(
    46                                 'title'  => esc_html__( 'Basic Field', 'your-textdomain-here' ),
    47                                 'id'     => 'opt-basic-fields',
    48                                 'desc'   => esc_html__( 'Redux Framework was created with the developer in mind. It allows for any theme developer to have an advanced theme panel with most of the features a developer would need. For more information check out the Github repo at:', 'your-textdomain-here' ) . '  <a href="https://github.com/ReduxFramework/Redux-Framework">https://github.com/ReduxFramework/Redux-Framework</a>',
    49                                 'icon'   => 'el-icon-cogs',
    50                                 'fields' => array(
    51                                         array(
    52                                                 'id'       => 'opt-checkbox',
    53                                                 'type'     => 'checkbox',
    54                                                 'title'    => esc_html__( 'Checkbox', 'your-textdomain-here' ),
    55                                                 'subtitle' => esc_html__( 'Basic Checkbox field.', 'your-textdomain-here' ),
    56                                                 'default'  => true,
    57                                         ),
    58                                         array(
    59                                                 'id'       => 'switch-on',
    60                                                 'type'     => 'switch',
    61                                                 'title'    => esc_html__( 'Switch On', 'your-textdomain-here' ),
    62                                                 'subtitle' => esc_html__( 'Look, it\'s on!', 'your-textdomain-here' ),
    63                                                 'default'  => 1,
    64                                         ),
    65                                 ),
    66                         ),
     77                                'codeEditor' => $cm_settings,
     78                                'mediaTitle' => esc_html__( 'Select gallery images', 'spartan-gallery' ),
     79                                'mediaButton' => esc_html__( 'Use selected images', 'spartan-gallery' ),
     80                        )
     81                );
     82        }
     83
     84        private static function meta( $post_id, $key, $default = '' ) {
     85                // metadata_exists(), not an emptiness check: update_post_meta() legitimately
     86                // stores '' when a checkbox is unchecked, and that must NOT be treated the
     87                // same as "never saved, show the default" or unchecked switches could never
     88                // actually be turned off.
     89                if ( ! metadata_exists( 'post', $post_id, $key ) ) {
     90                        return $default;
     91                }
     92                return get_post_meta( $post_id, $key, true );
     93        }
     94
     95        private static function tabs() {
     96                return array(
     97                        'layout'    => array( esc_html__( 'Gallery Layout Options', 'spartan-gallery' ), 'dashicons-layout' ),
     98                        'upload'    => array( esc_html__( 'Upload Images', 'spartan-gallery' ), 'dashicons-format-gallery' ),
     99                        'image'     => array( esc_html__( 'Image Options', 'spartan-gallery' ), 'dashicons-admin-generic' ),
     100                        'container' => array( esc_html__( 'Gallery Container Settings', 'spartan-gallery' ), 'dashicons-admin-appearance' ),
     101                        'css'       => array( esc_html__( 'Insert Custom CSS', 'spartan-gallery' ), 'dashicons-editor-code' ),
     102                );
     103        }
     104
     105        private static function render_nav( $active ) {
     106                echo '<div class="sg-options-nav">';
     107                foreach ( self::tabs() as $id => $tab ) {
     108                        list( $label, $icon ) = $tab;
     109                        $class = 'sg-options-nav-item' . ( $id === $active ? ' active' : '' );
     110                        echo '<button type="button" class="' . esc_attr( $class ) . '" data-panel="' . esc_attr( $id ) . '">';
     111                        echo '<span class="dashicons ' . esc_attr( $icon ) . '"></span>';
     112                        echo '<span class="sg-nav-label">' . esc_html( $label ) . '</span>';
     113                        echo '</button>';
     114                }
     115                echo '</div>';
     116        }
     117
     118        private static function section_open( $id, $title, $desc = '' ) {
     119                $active = ( 'layout' === $id );
     120                echo '<div class="sg-options-panel' . ( $active ? ' active' : '' ) . '" data-panel="' . esc_attr( $id ) . '">';
     121                echo '<h3 class="sg-options-section-title">' . esc_html( $title ) . '</h3>';
     122                if ( $desc ) {
     123                        echo '<p class="sg-options-section-desc">' . wp_kses_post( $desc ) . '</p>';
     124                }
     125                echo '<table class="form-table sg-options-table"><tbody>';
     126        }
     127
     128        private static function section_close() {
     129                echo '</tbody></table></div>';
     130        }
     131
     132        private static function row_open( $label, $for = '' ) {
     133                echo '<tr><th scope="row">';
     134                if ( $for ) {
     135                        echo '<label for="' . esc_attr( $for ) . '">' . esc_html( $label ) . '</label>';
     136                } else {
     137                        echo esc_html( $label );
     138                }
     139                echo '</th><td>';
     140        }
     141
     142        private static function row_close( $desc = '' ) {
     143                if ( $desc ) {
     144                        echo '<p class="description">' . wp_kses_post( $desc ) . '</p>';
     145                }
     146                echo '</td></tr>';
     147        }
     148
     149        public static function render( $post ) {
     150                wp_nonce_field( self::NONCE_ACTION, self::NONCE_NAME );
     151
     152                $gallery_id = $post->ID;
     153
     154                echo '<div class="sg-options-wrap">';
     155                self::render_nav( 'layout' );
     156                echo '<div class="sg-options-content">';
     157
     158                // Section 1: Gallery Layout Options.
     159                self::section_open( 'layout', esc_html__( 'Gallery Layout Options', 'spartan-gallery' ) );
     160                $layout = self::meta( $gallery_id, 'image_layout_select', 'value-1' );
     161                $layouts = array(
     162                        'value-1' => array( esc_html__( 'Freewall Chaotic', 'spartan-gallery' ), 'FlexFreewallTable.png' ),
     163                        'value-2' => array( esc_html__( 'Random', 'spartan-gallery' ), 'ImageFreewallGrid.png' ),
     164                        'value-3' => array( esc_html__( 'Fixed', 'spartan-gallery' ), 'NestedFreewallGrid.png' ),
     165                        'value-4' => array( esc_html__( 'Pinterest', 'spartan-gallery' ), 'PinterestFreewallGrid.png' ),
     166                        'value-5' => array( esc_html__( 'Hexagon', 'spartan-gallery' ), 'hexagon_layout.jpg' ),
     167                        'value-6' => array( esc_html__( '3D Slider', 'spartan-gallery' ), 'spartan_3D_layout.png' ),
     168                );
     169                echo '<tr><td colspan="2">';
     170                echo '<p class="description">' . esc_html__( 'Gallery layout looks exactly like the preview image. To change the aspect ratio, select the third layout, turn "Display Adjustable Image" ON under Image Options, and turn "Display thumbnail size" OFF. Width/height only apply to the third and sixth layouts; other layouts size images randomly for the grid.', 'spartan-gallery' ) . '</p>';
     171                echo '<div class="sg-image-select">';
     172                foreach ( $layouts as $value => $data ) {
     173                        list( $label, $file ) = $data;
     174                        $img_url = plugins_url( 'img/' . $file, __FILE__ );
     175                        $checked = checked( $layout, $value, false );
     176                        echo '<label class="sg-image-select-option' . ( $layout === $value ? ' selected' : '' ) . '">';
     177                        echo '<input type="radio" name="image_layout_select" value="' . esc_attr( $value ) . '" ' . $checked . ' />';
     178                        echo '<img src="' . esc_url( $img_url ) . '" alt="' . esc_attr( $label ) . '" />';
     179                        echo '<span>' . esc_html( $label ) . '</span>';
     180                        echo '</label>';
     181                }
     182                echo '</div>';
     183                echo '</td></tr>';
     184                self::section_close();
     185
     186                // Section 2: Upload Images.
     187                self::section_open( 'upload', esc_html__( 'Upload Images', 'spartan-gallery' ) );
     188                $uploaded_ids = self::meta( $gallery_id, 'spartan_gallery_uploaded_images', '' );
     189                self::row_open( esc_html__( 'Upload', 'spartan-gallery' ) );
     190                echo '<input type="hidden" id="spartan_gallery_uploaded_images" name="spartan_gallery_uploaded_images" value="' . esc_attr( $uploaded_ids ) . '" />';
     191                echo '<div id="sg-gallery-preview" class="sg-gallery-preview">';
     192                if ( ! empty( $uploaded_ids ) ) {
     193                        foreach ( explode( ',', $uploaded_ids ) as $att_id ) {
     194                                $att_id = absint( $att_id );
     195                                if ( ! $att_id ) {
     196                                        continue;
     197                                }
     198                                $thumb = wp_get_attachment_image_src( $att_id, 'thumbnail' );
     199                                if ( $thumb ) {
     200                                        echo '<span class="sg-gallery-thumb" data-id="' . esc_attr( $att_id ) . '"><img src="' . esc_url( $thumb[0] ) . '" /><a href="#" class="sg-gallery-remove" title="' . esc_attr__( 'Remove', 'spartan-gallery' ) . '">&times;</a></span>';
     201                                }
     202                        }
     203                }
     204                echo '</div>';
     205                echo '<p><button type="button" class="button" id="sg-gallery-select">' . esc_html__( 'Select / Manage Images', 'spartan-gallery' ) . '</button></p>';
     206                self::row_close();
     207                self::section_close();
     208
     209                // Section 3: Image Options.
     210                self::section_open( 'image', esc_html__( 'Image Options', 'spartan-gallery' ) );
     211
     212                self::row_open( esc_html__( 'Display Adjustable Image', 'spartan-gallery' ), 'display_original' );
     213                $display_original = self::meta( $gallery_id, 'display_original', '' );
     214                echo '<label class="sg-switch"><input type="checkbox" id="display_original" name="display_original" value="1" ' . checked( $display_original, '1', false ) . ' /> ' . esc_html__( 'Enabled', 'spartan-gallery' ) . '</label>';
     215                self::row_close( esc_html__( '"Display thumbnail size" can\'t be turned on when this setting is turned on.', 'spartan-gallery' ) );
     216
     217                self::row_open( esc_html__( 'Image width (PX)', 'spartan-gallery' ), 'image_width' );
     218                $image_width = self::meta( $gallery_id, 'image_width', 150 );
     219                echo '<div class="sg-slider" id="image_width_slider" data-target="image_width" data-min="0" data-max="2000" data-step="1"></div>';
     220                echo '<input type="text" class="sg-slider-value" id="image_width" name="image_width" value="' . esc_attr( $image_width ) . '" readonly="readonly" />';
     221                self::row_close();
     222
     223                self::row_open( esc_html__( 'Image height (PX)', 'spartan-gallery' ), 'image_height' );
     224                $image_height = self::meta( $gallery_id, 'image_height', 150 );
     225                echo '<div class="sg-slider" id="image_height_slider" data-target="image_height" data-min="0" data-max="2000" data-step="1"></div>';
     226                echo '<input type="text" class="sg-slider-value" id="image_height" name="image_height" value="' . esc_attr( $image_height ) . '" readonly="readonly" />';
     227                self::row_close();
     228
     229                self::row_open( esc_html__( 'Img measure value', 'spartan-gallery' ), 'image_measure_value' );
     230                $measure = self::meta( $gallery_id, 'image_measure_value', 'px' );
     231                echo '<select id="image_measure_value" name="image_measure_value">';
     232                foreach ( array( 'px' => 'px', '%' => '%', 'vh' => 'vh/vw', 'rem' => 'rem' ) as $val => $label ) {
     233                        echo '<option value="' . esc_attr( $val ) . '" ' . selected( $measure, $val, false ) . '>' . esc_html( $label ) . '</option>';
     234                }
     235                echo '</select>';
     236                self::row_close();
     237
     238                self::row_open( esc_html__( 'Display thumbnail size', 'spartan-gallery' ), 'thumbnail_options' );
     239                $thumb_opt = self::meta( $gallery_id, 'thumbnail_options', '1' );
     240                echo '<label class="sg-switch"><input type="checkbox" id="thumbnail_options" name="thumbnail_options" value="1" ' . checked( $thumb_opt, '1', false ) . ' /> ' . esc_html__( 'Enabled', 'spartan-gallery' ) . '</label>';
     241                self::row_close( esc_html__( '"Display Adjustable Image" can\'t be turned on when this setting is turned on.', 'spartan-gallery' ) );
     242
     243                self::row_open( esc_html__( 'Select Thumbnail Size', 'spartan-gallery' ), 'thumbnail_size' );
     244                $thumb_size = self::meta( $gallery_id, 'thumbnail_size', 'medium_large' );
     245                $thumb_sizes = array(
     246                        'thumbnail'    => esc_html__( 'Thumbnail (default 150px x 150px max)', 'spartan-gallery' ),
     247                        'medium'       => esc_html__( 'Medium resolution (default 300px x 300px max)', 'spartan-gallery' ),
     248                        'medium_large' => esc_html__( 'Medium Large resolution (default 768px x 0px max)', 'spartan-gallery' ),
     249                        'large'        => esc_html__( 'Large resolution (default 1024px x 1024px max)', 'spartan-gallery' ),
     250                        'original'     => esc_html__( 'Original image resolution (unmodified)', 'spartan-gallery' ),
     251                );
     252                echo '<select id="thumbnail_size" name="thumbnail_size">';
     253                foreach ( $thumb_sizes as $val => $label ) {
     254                        echo '<option value="' . esc_attr( $val ) . '" ' . selected( $thumb_size, $val, false ) . '>' . esc_html( $label ) . '</option>';
     255                }
     256                echo '</select>';
     257                self::row_close();
     258
     259                self::row_open( esc_html__( 'Image Margin (PX)', 'spartan-gallery' ), 'img_margin' );
     260                $img_margin = self::meta( $gallery_id, 'img_margin', 20 );
     261                echo '<input type="text" class="sg-spinner" id="img_margin" name="img_margin" value="' . esc_attr( $img_margin ) . '" data-min="0" data-max="100" data-step="1" />';
     262                self::row_close();
     263
     264                self::section_close();
     265
     266                // Section 5: Gallery Container Settings.
     267                self::section_open( 'container', esc_html__( 'Gallery Container Settings', 'spartan-gallery' ) );
     268
     269                self::row_open( esc_html__( 'Turn settings On/Off', 'spartan-gallery' ), 'container_settings_on_off' );
     270                $container_on = self::meta( $gallery_id, 'container_settings_on_off', '' );
     271                echo '<label class="sg-switch"><input type="checkbox" id="container_settings_on_off" name="container_settings_on_off" value="1" ' . checked( $container_on, '1', false ) . ' /> ' . esc_html__( 'Enabled', 'spartan-gallery' ) . '</label>';
     272                self::row_close();
     273
     274                self::row_open( esc_html__( 'Container dimensions (Width/Height)', 'spartan-gallery' ) );
     275                $dims = self::meta( $gallery_id, 'container_height_width_range', array() );
     276                $dims = wp_parse_args(
     277                        is_array( $dims ) ? $dims : array(),
     278                        array( 'width' => '200px', 'height' => '' )
     279                );
     280                list( $w_num, $w_unit ) = self::split_length( $dims['width'], '200', 'px' );
     281                list( $h_num, $h_unit ) = self::split_length( $dims['height'], '', 'px' );
     282                echo '<div class="sg-dimensions">';
     283                echo '<span><label>' . esc_html__( 'Width', 'spartan-gallery' ) . '</label> <input type="text" name="container_width_num" value="' . esc_attr( $w_num ) . '" size="6" /> ';
     284                echo self::unit_select( 'container_width_unit', $w_unit );
     285                echo '</span> <span><label>' . esc_html__( 'Height', 'spartan-gallery' ) . '</label> <input type="text" name="container_height_num" value="' . esc_attr( $h_num ) . '" size="6" /> ';
     286                echo self::unit_select( 'container_height_unit', $h_unit );
     287                echo '</span>';
     288                echo '</div>';
     289                self::row_close();
     290
     291                self::row_open( esc_html__( 'Background Color', 'spartan-gallery' ), 'container_background_color' );
     292                $container_bg = self::meta( $gallery_id, 'container_background_color', '#FFFFFF' );
     293                echo '<input type="text" class="sg-color-field" id="container_background_color" name="container_background_color" value="' . esc_attr( $container_bg ) . '" data-default-color="#FFFFFF" />';
     294                self::row_close();
     295
     296                self::row_open( esc_html__( 'Border Option', 'spartan-gallery' ) );
     297                $border = self::meta( $gallery_id, 'container_border', array() );
     298                $border = wp_parse_args(
     299                        is_array( $border ) ? $border : array(),
    67300                        array(
    68                                 'title'      => esc_html__( 'Text Field', 'your-textdomain-here' ),
    69                                 'desc'       => esc_html__( 'Redux Framework was created with the developer in mind. It allows for any theme developer to have an advanced theme panel with most of the features a developer would need. For more information check out the Github repo at:', 'your-textdomain-here' ) . '  <a href="https://github.com/ReduxFramework/Redux-Framework">https://github.com/ReduxFramework/Redux-Framework</a>',
    70                                 'icon'       => 'el-icon-cog',
    71                                 'id'         => 'opt-text-fields',
    72                                 'subsection' => true,
    73                                 'fields'     => array(
    74                                         array(
    75                                                 'title' => esc_html__( 'Text Field', 'your-textdomain-here' ),
    76                                                 'id'    => 'opt-text',
    77                                                 'type'  => 'text',
    78                                         ),
    79                                 ),
    80                         ),
     301                                'border-color'  => '#000000',
     302                                'border-style'  => 'none',
     303                                'border-top'    => '',
     304                                'border-right'  => '',
     305                                'border-bottom' => '',
     306                                'border-left'   => '',
     307                        )
     308                );
     309                echo '<div class="sg-border">';
     310                echo '<span><label>' . esc_html__( 'Style', 'spartan-gallery' ) . '</label> <select name="container_border[border-style]">';
     311                foreach ( array( 'none', 'solid', 'dashed', 'dotted', 'double', 'groove', 'ridge', 'inset', 'outset' ) as $style ) {
     312                        echo '<option value="' . esc_attr( $style ) . '" ' . selected( $border['border-style'], $style, false ) . '>' . esc_html( $style ) . '</option>';
     313                }
     314                echo '</select></span> ';
     315                echo '<span><label>' . esc_html__( 'Color', 'spartan-gallery' ) . '</label> <input type="text" class="sg-color-field" name="container_border[border-color]" value="' . esc_attr( $border['border-color'] ) . '" data-default-color="#000000" /></span>';
     316                echo '<div class="sg-border-widths">';
     317                $border_sides = array(
     318                        'border-top'    => __( 'Top', 'spartan-gallery' ),
     319                        'border-right'  => __( 'Right', 'spartan-gallery' ),
     320                        'border-bottom' => __( 'Bottom', 'spartan-gallery' ),
     321                        'border-left'   => __( 'Left', 'spartan-gallery' ),
     322                );
     323                foreach ( $border_sides as $side => $side_label ) {
     324                        echo '<span><label>' . esc_html( $side_label ) . '</label> <input type="text" name="container_border[' . esc_attr( $side ) . ']" value="' . esc_attr( $border[ $side ] ) . '" size="6" placeholder="e.g. 1px" /></span>';
     325                }
     326                echo '</div>';
     327                echo '</div>';
     328                self::row_close( esc_html__( 'Only applies when "Turn settings On/Off" above is enabled.', 'spartan-gallery' ) );
     329
     330                self::section_close();
     331
     332                // Section 6: Insert Custom CSS.
     333                self::section_open( 'css', esc_html__( 'Insert Custom CSS', 'spartan-gallery' ) );
     334                self::row_open( esc_html__( 'CSS Code', 'spartan-gallery' ), 'add_extra_css' );
     335                $extra_css = self::meta( $gallery_id, 'add_extra_css', '' );
     336                echo '<textarea id="add_extra_css" name="add_extra_css" rows="10" class="large-text code">' . esc_textarea( $extra_css ) . '</textarea>';
     337                self::row_close( esc_html__( 'Paste your CSS code here. The gallery container HTML class is .spartan-gallery-wrapper', 'spartan-gallery' ) );
     338                self::section_close();
     339
     340                echo '</div>'; // .sg-options-content
     341                echo '</div>'; // .sg-options-wrap
     342        }
     343
     344        private static function split_length( $value, $default_num, $default_unit ) {
     345                $value = trim( (string) $value );
     346                if ( '' === $value ) {
     347                        return array( $default_num, $default_unit );
     348                }
     349                if ( preg_match( '/^(-?[0-9.]+)(px|em|rem|%|vh|vw)?$/', $value, $m ) ) {
     350                        return array( $m[1], isset( $m[2] ) ? $m[2] : $default_unit );
     351                }
     352                return array( $default_num, $default_unit );
     353        }
     354
     355        private static function unit_select( $name, $selected_unit ) {
     356                $out = '<select name="' . esc_attr( $name ) . '">';
     357                foreach ( array( 'px', 'em', 'rem', '%' ) as $unit ) {
     358                        $out .= '<option value="' . esc_attr( $unit ) . '" ' . selected( $selected_unit, $unit, false ) . '>' . esc_html( $unit ) . '</option>';
     359                }
     360                $out .= '</select>';
     361                return $out;
     362        }
     363
     364        public static function save( $post_id ) {
     365                if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
     366                        return;
     367                }
     368
     369                if ( ! isset( $_POST[ self::NONCE_NAME ] ) || ! wp_verify_nonce( wp_unslash( $_POST[ self::NONCE_NAME ] ), self::NONCE_ACTION ) ) {
     370                        return;
     371                }
     372
     373                if ( get_post_type( $post_id ) !== self::POST_TYPE ) {
     374                        return;
     375                }
     376
     377                if ( ! current_user_can( 'edit_post', $post_id ) ) {
     378                        return;
     379                }
     380
     381                $layout = isset( $_POST['image_layout_select'] ) ? sanitize_text_field( wp_unslash( $_POST['image_layout_select'] ) ) : 'value-1';
     382                if ( ! in_array( $layout, array( 'value-1', 'value-2', 'value-3', 'value-4', 'value-5', 'value-6' ), true ) ) {
     383                        $layout = 'value-1';
     384                }
     385                update_post_meta( $post_id, 'image_layout_select', $layout );
     386
     387                if ( isset( $_POST['spartan_gallery_uploaded_images'] ) ) {
     388                        $ids = array_filter( array_map( 'absint', explode( ',', wp_unslash( $_POST['spartan_gallery_uploaded_images'] ) ) ) );
     389                        update_post_meta( $post_id, 'spartan_gallery_uploaded_images', implode( ',', $ids ) );
     390                }
     391
     392                update_post_meta( $post_id, 'display_original', isset( $_POST['display_original'] ) ? '1' : '' );
     393                update_post_meta( $post_id, 'thumbnail_options', isset( $_POST['thumbnail_options'] ) ? '1' : '' );
     394                update_post_meta( $post_id, 'container_settings_on_off', isset( $_POST['container_settings_on_off'] ) ? '1' : '' );
     395
     396                update_post_meta( $post_id, 'image_width', isset( $_POST['image_width'] ) ? min( 2000, absint( $_POST['image_width'] ) ) : 150 );
     397                update_post_meta( $post_id, 'image_height', isset( $_POST['image_height'] ) ? min( 2000, absint( $_POST['image_height'] ) ) : 150 );
     398                update_post_meta( $post_id, 'img_margin', isset( $_POST['img_margin'] ) ? min( 100, absint( $_POST['img_margin'] ) ) : 20 );
     399
     400                $measure = isset( $_POST['image_measure_value'] ) ? sanitize_text_field( wp_unslash( $_POST['image_measure_value'] ) ) : 'px';
     401                update_post_meta( $post_id, 'image_measure_value', in_array( $measure, array( 'px', '%', 'vh', 'rem' ), true ) ? $measure : 'px' );
     402
     403                $thumb_size = isset( $_POST['thumbnail_size'] ) ? sanitize_text_field( wp_unslash( $_POST['thumbnail_size'] ) ) : 'medium_large';
     404                update_post_meta( $post_id, 'thumbnail_size', in_array( $thumb_size, array( 'thumbnail', 'medium', 'medium_large', 'large', 'original' ), true ) ? $thumb_size : 'medium_large' );
     405
     406                $container_bg = isset( $_POST['container_background_color'] ) ? sanitize_hex_color( wp_unslash( $_POST['container_background_color'] ) ) : '';
     407                update_post_meta( $post_id, 'container_background_color', $container_bg ? $container_bg : '#FFFFFF' );
     408
     409                $w_num  = isset( $_POST['container_width_num'] ) ? sanitize_text_field( wp_unslash( $_POST['container_width_num'] ) ) : '';
     410                $w_unit = isset( $_POST['container_width_unit'] ) ? sanitize_text_field( wp_unslash( $_POST['container_width_unit'] ) ) : 'px';
     411                $h_num  = isset( $_POST['container_height_num'] ) ? sanitize_text_field( wp_unslash( $_POST['container_height_num'] ) ) : '';
     412                $h_unit = isset( $_POST['container_height_unit'] ) ? sanitize_text_field( wp_unslash( $_POST['container_height_unit'] ) ) : 'px';
     413                update_post_meta(
     414                        $post_id,
     415                        'container_height_width_range',
    81416                        array(
    82                                 'title'  => esc_html__( 'Color Field', 'your-textdomain-here' ),
    83                                 'desc'   => esc_html__( 'Redux Framework was created with the developer in mind. It allows for any theme developer to have an advanced theme panel with most of the features a developer would need. For more information check out the Github repo at:', 'your-textdomain-here' ) . '  <a href="https://github.com/ReduxFramework/Redux-Framework">https://github.com/ReduxFramework/Redux-Framework</a>',
    84                                 'icon'   => 'el-icon-pencil',
    85                                 'id'     => 'color-section',
    86                                 'fields' => array(
    87                                         array(
    88                                                 'id'       => 'opt-color',
    89                                                 'type'     => 'color',
    90                                                 'title'    => esc_html__( 'Color Field', 'your-textdomain-here' ),
    91                                                 'default'  => '#333333',
    92                                                 'required' => array( 'opt-layout', '=', 'on' ),
    93                                         ),
    94                                 ),
    95                         ),
    96                 ),
    97         )
    98 );
    99 
    100 // Metabox sidebar.
    101 Redux_Metaboxes::set_box(
    102         $opt_name,
    103         array(
    104                 'id'         => 'opt-metaboxes-3',
    105                 'post_types' => array( 'spartan_gallery_type' ),
    106                 'position'   => 'side', // normal, advanced, side.
    107                 'priority'   => 'high', // high, core, default, low.
    108                 'sections'   => array(
    109                         array(
    110                                 'id'         => 'test-sidebar',
    111                                 'icon_class' => 'icon-large',
    112                                 'icon'       => 'el-icon-home',
    113                                 'fields'     => array(
    114                                         array(
    115                                                 'id'      => 'sidebar',
    116                                                 'title'   => esc_html__( 'Sidebar', 'your-textdomain-here' ),
    117                                                 'desc'    => esc_html__( 'Please select the sidebar you would like to display on this page. Note: You must first create the sidebar under Appearance > Widgets.', 'your-textdomain-here' ),
    118                                                 'type'    => 'select',
    119                                                 'data'    => 'sidebars',
    120                                                 'default' => 'None',
    121                                         ),
    122                                 ),
    123                         ),
    124                 ),
    125         )
    126 );
    127 */
    128 // Standard metabox.
    129 Redux_Metaboxes::set_box(
    130         $opt_name,
    131         array(
    132                 'id'         => 'opt-metaboxes-4',
    133                 'title'      => esc_html__( 'Spartan Gallery Options', 'your-textdomain-here' ),
    134                 'post_types' => array( 'spartan_gallery_type' ), // Define post types where this metabox will appear
    135                 'position'   => 'normal', // normal, advanced, side.
    136                 'priority'   => 'high',   // high, core, default, low.
    137                 'sections'   => array(
    138                         // Spartan Gallery First Section
    139                         array(
    140                                 'title'  => esc_html__( 'Gallery Layout Options', 'your-textdomain-here' ),
    141                                 'id'     => 'spartan_gallery_first_section',
    142                                 'icon'   => 'fa-solid fa-bars',
    143                                 'fields' => array(
    144                                         array(
    145                                                 'id'       => 'image_layout_select',
    146                                                 'type'     => 'image_select',
    147                                                 'title'    => esc_html__( 'Select Gallery Layout', 'your-textdomain-here' ),
    148                                                 'subtitle'      => esc_html__( 'Here you select layout of the gallery.
    149                                                         Gallery layout looks exactly like on the image. If you wish to change the apect radio of gallery, select the
    150                                                         third image and click "Display Adjustable Image" ON under "Image options" and switch "Display thumbnail size" OFF. From there you could change image width and height. This settings works
    151                                                         only with third and sixth layout. In other layouts image size are generated randomly for the grid.', 'your-textdomain-here' ),
    152                                                 'options'  => array(
    153                                                         'value-1' => plugins_url( '/img/FlexFreewallTable.png',  __FILE__ ),
    154                                                         'value-2' => plugins_url( '/img/ImageFreewallGrid.png',  __FILE__ ),
    155                                                         'value-3' => plugins_url( 'img/NestedFreewallGrid.png',  __FILE__ ),
    156                                                         'value-4' => plugins_url( '/img/PinterestFreewallGrid.png',  __FILE__ ),
    157                                                         'value-5' => plugins_url( '/img/hexagon_layout.jpg',  __FILE__ ),
    158                                                         'value-6' => plugins_url( '/img/spartan_3D_layout.png',  __FILE__ ),
    159                                                 ),
    160                                                 'radio'    => true,
    161                                                 'default'  => 'value-1',
    162                                         ),
    163                                 ),
    164                         ),
    165 
    166                         // Spartan Gallery Second Section
    167                         array(
    168                                 'title'  => esc_html__( 'Upload Images', 'your-textdomain-here' ),
    169                                 'id'     => 'spartan_gallery_second_section',
    170                                 'icon'   => 'fa-regular fa-image',
    171                                 'fields' => array(
    172                                         array(
    173                                                 'id'      => 'spartan_gallery_uploaded_images',
    174                                                 'type'    => 'gallery',
    175                                                 'title'   => esc_html__( 'Upload', 'your-textdomain-here' ),
    176                                                 'options' => array(
    177                                                         'attach'      => true,
    178                                                         'filecount'   => '101',
    179                                                         'auto-upload' => true,
    180                                                 ),
    181                                         ),
    182                                        
    183                                 ),
    184                         ),
    185 
    186                         // Image Options
    187                         array(
    188                                 'title'  => esc_html__( 'Image Options', 'your-textdomain-here' ),
    189                                 'id'     => 'image_options',
    190                                 'icon'   => 'fa-solid fa-sliders',
    191                                 'fields' => array(
    192                                         array(
    193                                                 'id'      => 'display_original',
    194                                                 'type'    => 'switch',
    195                                                 'title'   => esc_html__( 'Display Adjustable Image', 'your-textdomain-here' ),
    196                                                 'subtitle'      => esc_html__( '"Display thumbnail size" setting cant be turned on when when this setting is turned on', 'your-textdomain-here' ),
    197                                                 'default' => false,
    198                                         ),
    199                                         array(
    200                                                 'id'      => 'image_width',
    201                                                 'type'          => 'slider',
    202                                                 'title'         => esc_html__( 'Image width Steps (1) PX', 'your-textdomain-here' ),
    203                                                 //'subtitle'      => esc_html__( 'px', 'your-textdomain-here' ),
    204                                                 //'desc'          => esc_html__( 'Slider description. Min: 0, max: 800, step: 5, default value: 75', 'your-textdomain-here' ),
    205                                                 'default'       => 150,
    206                                                 'min'           => 0,
    207                                                 'step'          => 1,
    208                                                 'max'           => 2000,
    209                                                 'display_value' => 'text',
    210                                                 'output'        => array( '.site-content' => 'max-width' ),
    211                                         ),
    212                                         array(
    213                                                 'id'      => 'image_height',
    214                                                 'type'          => 'slider',
    215                                                 'title'         => esc_html__( 'Image height Steps (1) PX', 'your-textdomain-here' ),
    216                                                 //'subtitle'      => esc_html__( 'px', 'your-textdomain-here' ),
    217                                                 //'desc'          => esc_html__( 'Slider description. Min: 0, max: 800, step: 5, default value: 75', 'your-textdomain-here' ),
    218                                                 'default'       => 150,
    219                                                 'min'           => 0,
    220                                                 'step'          => 1,
    221                                                 'max'           => 2000,
    222                                                 'display_value' => 'text',
    223                                                 'output'        => array( '.site-content' => 'max-width' ),
    224                                         ),
    225                                         array(
    226                                                 'id'             => 'image_measure_value',
    227                                                 'type'           => 'select',
    228                                                 'title'          => esc_html__( 'Img measure value', 'your-textdomain-here' ),
    229                                                 'options'        => array(
    230                                                         'px'   => 'px',
    231                                                         '%'    => '%',
    232                                                         'vh'   => 'vh/vw',
    233                                                         'rem'  => 'rem',
    234                                                 ),
    235                                                 'default_option' => esc_html__( 'Select image measure value', 'your-textdomain-here' ),
    236                                                 'default'        => 'px',
    237                                         ),
    238                                         array(
    239                                                 'id'      => 'thumbnail_options',
    240                                                 'type'    => 'switch',
    241                                                 'title'   => esc_html__( 'Display thumbnail size', 'your-textdomain-here' ),
    242                                                 'subtitle'      => esc_html__( '"Display Adjustable Image " setting cant be turned on when when this setting is turned on', 'your-textdomain-here' ),
    243                                                 'default' => true,
    244                                         ),
    245                                         array(
    246                                                 'id'             => 'thumbnail_size',
    247                                                 'type'           => 'select',
    248                                                 'title'          => esc_html__( 'Select Thumbnail Size', 'your-textdomain-here' ),
    249                                                 'options'        => array(
    250                                                         'thumbnail'      => 'Thumbnail (default 150px x 150px max)',
    251                                                         'medium'         => 'Medium resolution (default 300px x 300px max)',
    252                                                         'medium_large'   => 'Medium Large resolution (default 768px x 0px max)',
    253                                                         'large'          => 'Large resolution (default 1024px x 1024px max)',
    254                                                         'original'       => 'Original image resolution (unmodified)',
    255                                                 ),
    256                                                 'default_option' => esc_html__( 'Select Image Thumbnail Size', 'your-textdomain-here' ),
    257                                                 'default'        => 'medium_large',
    258                                         ),
    259                                         array(
    260                                                 'id'      => 'img_margin',
    261                                                 'type'     => 'spinner',
    262                                                 'title'    => esc_html__('Image Margin (PX)', 'your-textdomain-here'),
    263                                                 //'subtitle' => esc_html__('No validation can be done on this field type','your-textdomain-here'),
    264                                                 //'desc'     => esc_html__('JQuery UI spinner description. Min:20, max: 100, step:20, default value: 40', 'your-textdomain-here'),
    265                                                 'default'  => '20',
    266                                                 'min'      => '0',
    267                                                 'step'     => '1',
    268                                                 'max'      => '100',
    269                                                 //'output'   => array( '.content-area' => 'max-width' ),
    270                                         ),
    271                                         /*
    272                                         array(
    273                                                 'id'      => 'img_border',
    274                                                 'type'     => 'border',
    275                                                 'title'    => esc_html__('Image Style Settings', 'your-project-name'),
    276                                                 //'subtitle' => esc_html__('Only color validation can be done on this field type', 'your-project-name'),
    277                                                 //'output'   => array('.site-header'),
    278                                                 'desc'     => esc_html__('This is the description field, again good for additional info.', 'your-project-name'),
    279                                                 'default'  => array(
    280                                                         'border-color'  => ' ',
    281                                                         'border-style'  => ' ',
    282                                                         'border-top'    => ' ',
    283                                                         'border-right'  => ' ',
    284                                                         'border-bottom' => ' ',
    285                                                         'border-left'   => ' '
    286     )
    287                                         ),
    288                                         */
    289                                 ),
    290                         ),
    291 
    292                         // Button Style Options
    293                         array(
    294                                 'title'  => esc_html__( 'Text Style Options', 'your-textdomain-here' ),
    295                                 'id'     => 'button_style_options',
    296                                 'icon'   => 'fa-solid fa-gears',
    297                                 'fields' => array(
    298                                         array(
    299                                                 'id'      => 'display_text',
    300                                                 'type'    => 'switch',
    301                                                 'title'   => esc_html__( 'Display text under image', 'your-textdomain-here' ),
    302                                                 'default' => false,
    303                                         ),
    304                                         array(
    305                                                 'id'      => 'textbox_height_range',
    306                                                 'type'          => 'slider',
    307                                                 'title'         => esc_html__( 'Text conteiner height, value is in %', 'your-textdomain-here' ),
    308                                                 //'subtitle'      => esc_html__( 'px', 'your-textdomain-here' ),
    309                                                 //'desc'          => esc_html__( 'Slider description. Min: 0, max: 800, step: 5, default value: 75', 'your-textdomain-here' ),
    310                                                 'default'       => 50,
    311                                                 'min'           => 0,
    312                                                 'step'          => 1,
    313                                                 'max'           => 100,
    314                                                 'display_value' => 'text',
    315                                                 //'output'        => array( '.site-content' => 'max-width' ),
    316                                         ),
    317                        
    318                                         array(
    319                                                 'id'     => 'info_background_color',
    320                                                 'type'     => 'color',
    321                                                 'title'    => esc_html__('Text box Background Color', 'your-textdomain-here'),
    322                                                 //'subtitle' => esc_html__('Pick a background color for the theme (default: #fff).', 'your-textdomain-here'),
    323                                                 'default'  => '#FFFFFF',
    324                                                 'validate' => 'color',
    325                                         ),
    326                                        
    327                                         array(
    328                                                  'id'      => 'font_family',
    329                                                 'type'        => 'typography',
    330                                                 'title'       => esc_html__('Typography', 'your-textdomain-here'),
    331                                                 'google'      => true,
    332                                                 'font-backup' => false,
    333                                                 'font-subsets' => false,
    334                                                 //'output'      => array('h2.site-description'),
    335                                                 'units'       =>'px',
    336                                                 'subtitle'    => esc_html__('Text box typography.', 'your-textdomain-here'),
    337                                                 'default'     => array(
    338                                                         'color'       => '#333',
    339                                                         'font-style'  => '200',
    340                                                         'font-family' => 'Abel',
    341                                                         'google'      => true,
    342                                                         'font-size'   => '9px',
    343                                                         'line-height' => '0'
    344                                                 ),
    345                                         ),     
    346                                 ),
    347                         ),
    348 
    349                         array(
    350                                 'title'  => esc_html__( 'Gallery Container Settings', 'your-textdomain-here' ),
    351                                 'id'     => 'gallery_container_first_section',
    352                                 'icon'   => 'fa-solid fa-screwdriver-wrench',
    353                                 'fields' => array(
    354                                        
    355                                         array(
    356                                                 'id'      => 'container_settings_on_off',
    357                                                 'type'    => 'switch',
    358                                                 'title'   => esc_html__( 'Turn settings On/Off', 'your-textdomain-here' ),
    359                                                 'default' => false,
    360                                         ),
    361                                         array(
    362                                                 'id'      => 'container_height_width_range',
    363                                                 'type'     => 'dimensions',
    364                                                         'units'    => array('em','px','%'),
    365                                                         'title'    => esc_html__('Container dimensions (Width/Height) Option', 'your-textdomain-here'),
    366                                                         //'subtitle' => esc_html__('Allow your users to choose width, height, and/or unit.', 'your-textdomain-here'),
    367                                                         //'desc'     => esc_html__('Enable or disable any piece of this field. Width, Height, or Units.', 'your-textdomain-here'),
    368                                                         'output'   => array('.spartan-gallery-wrapper'),
    369                                                         'default'  => array(
    370                                                                 'Width'   => '200',
    371                                                                 'Height'  => ''
    372                                                         ),
    373                                         ),
    374                                         array(
    375                                                 'id'     => 'container_background_color',
    376                                                 'type'     => 'color',
    377                                                 'title'    => esc_html__('Background Color', 'your-textdomain-here'),
    378                                                 //'subtitle' => esc_html__('Pick a background color for the theme (default: #fff).', 'your-textdomain-here'),
    379                                                 //'output'   => array('.spartan-gallery-wrapper'),     
    380                                                
    381                                                 'default'  => '#FFFFFF',
    382                                                 'validate' => 'color',
    383                                         ),
    384                                         array(
    385                                                 'id'     => 'container_border',
    386                                                 'type'     => 'border',
    387                                                 'title'    => esc_html__('Border Option', 'your-project-name'),
    388                                                 //'subtitle' => esc_html__('Only color validation can be done on this field type', 'your-project-name'),
    389                                                 //'output'   => array('.spartan-gallery-wrapper'),
    390                                                 //'desc'     => esc_html__('.spartan-gallery-wrapper'.', 'your-project-name'),
    391                                                 'default'  => array(
    392                                                         'border-color'  => ' ',
    393                                                         'border-style'  => 'none',
    394                                                         'border-top'    => ' ',
    395                                                         'border-right'  => ' ',
    396                                                         'border-bottom' => ' ',
    397                                                         'border-left'   => ' '
    398                                                 ),
    399                                         ),
    400                                 ),
    401                         ),
    402 
    403                        
    404                         array(
    405                                 'title'  => esc_html__( 'Insert Custom CSS', 'your-textdomain-here' ),
    406                                 'id'     => 'insert_extra_css_section',
    407                                 'icon'   => 'fa-solid fa-bars-progress',
    408                                 'fields' => array(
    409                                         array(
    410                                                 'id'      => 'add_extra_css',
    411                                                 'type'     => 'ace_editor',
    412                                                 'title'    => esc_html__('CSS Code', 'your-project-name'),
    413                                                 'subtitle' => esc_html__('Paste your CSS code here. Image container HTML class is .spartan-gallery-wrapper', 'your-project-name'),
    414                                                 'desc'     => esc_html__('Image container HTML class is .spartan-gallery-wrapper', 'your-project-name'),
    415                                                 'mode'     => 'css',
    416                                                 'theme'    => 'monokai',
    417                                                 'desc'     => 'Possible modes can be found at https://ace.c9.io/.',
    418                                                 //'default'  => "#header{\nmargin: 0 auto;\n}"
    419                                         ),
    420                                        
    421                                 ),
    422                         ),
    423 
    424                         array(
    425                                 'title'  => esc_html__( 'Import/Export Options', 'your-textdomain-here' ),
    426                                 //'id'     => 'insert_extra_css_section',
    427                                 'icon'   => 'fa-solid fa-bars-progress',
    428                                 'fields' => array(
    429                                        
    430                                         array(
    431                                                 'id'            => 'opt-import-export',
    432                                                 'type'          => 'import_export',
    433                                                 'title'         => 'Import Export',
    434                                                 'subtitle'      => 'Save and restore your Redux options',
    435                                                 'full_width'    => false,
    436                                         ),
    437                                 ),
    438                         ),
    439 
    440 
    441                
    442 
    443 
    444 
    445                 ),
    446         )
    447 );
    448 
    449 
     417                                'width'  => ( '' !== $w_num && is_numeric( $w_num ) ) ? $w_num . $w_unit : '',
     418                                'height' => ( '' !== $h_num && is_numeric( $h_num ) ) ? $h_num . $h_unit : '',
     419                        )
     420                );
     421
     422                if ( isset( $_POST['container_border'] ) && is_array( $_POST['container_border'] ) ) {
     423                        $raw = wp_unslash( $_POST['container_border'] );
     424                        $style_allowed = array( 'none', 'solid', 'dashed', 'dotted', 'double', 'groove', 'ridge', 'inset', 'outset' );
     425                        $border_color  = isset( $raw['border-color'] ) ? sanitize_hex_color( $raw['border-color'] ) : '';
     426                        update_post_meta(
     427                                $post_id,
     428                                'container_border',
     429                                array(
     430                                        'border-color'  => $border_color ? $border_color : '#000000',
     431                                        'border-style'  => isset( $raw['border-style'] ) && in_array( $raw['border-style'], $style_allowed, true ) ? $raw['border-style'] : 'none',
     432                                        'border-top'    => isset( $raw['border-top'] ) ? sanitize_text_field( $raw['border-top'] ) : '',
     433                                        'border-right'  => isset( $raw['border-right'] ) ? sanitize_text_field( $raw['border-right'] ) : '',
     434                                        'border-bottom' => isset( $raw['border-bottom'] ) ? sanitize_text_field( $raw['border-bottom'] ) : '',
     435                                        'border-left'   => isset( $raw['border-left'] ) ? sanitize_text_field( $raw['border-left'] ) : '',
     436                                )
     437                        );
     438                }
     439
     440                if ( isset( $_POST['add_extra_css'] ) ) {
     441                        update_post_meta( $post_id, 'add_extra_css', wp_strip_all_tags( wp_unslash( $_POST['add_extra_css'] ) ) );
     442                }
     443        }
     444}
     445
     446Spartan_Gallery_Options::init();
  • spartan-gallery/trunk/includes/class-spartan-gallery-activator.php

    r2145680 r3619020  
    2121 * @author     Freelancer Martin <developerforwebsites@gmail.com>
    2222 */
     23
     24if ( ! defined( 'WPINC' ) ) {
     25        die;
     26}
     27
    2328class Spartan_Gallery_Activator {
    2429
  • spartan-gallery/trunk/includes/class-spartan-gallery-deactivator.php

    r2145680 r3619020  
    2121 * @author     Freelancer Martin <developerforwebsites@gmail.com>
    2222 */
     23
     24if ( ! defined( 'WPINC' ) ) {
     25        die;
     26}
     27
    2328class Spartan_Gallery_Deactivator {
    2429
  • spartan-gallery/trunk/includes/class-spartan-gallery-i18n.php

    r2145680 r3619020  
    2525 * @author     Freelancer Martin <developerforwebsites@gmail.com>
    2626 */
     27
     28if ( ! defined( 'WPINC' ) ) {
     29        die;
     30}
     31
    2732class Spartan_Gallery_i18n {
    2833
  • spartan-gallery/trunk/includes/class-spartan-gallery-loader.php

    r2145680 r3619020  
    2222 * @author     Freelancer Martin <developerforwebsites@gmail.com>
    2323 */
     24
     25if ( ! defined( 'WPINC' ) ) {
     26        die;
     27}
     28
    2429class Spartan_Gallery_Loader {
    2530
  • spartan-gallery/trunk/includes/class-spartan-gallery.php

    r3204032 r3619020  
    2828 * @author     Freelancer Martin <developerforwebsites@gmail.com>
    2929 */
     30
     31if ( ! defined( 'WPINC' ) ) {
     32        die;
     33}
     34
    3035class Spartan_Gallery {
    3136
    … …  
    137142
    138143                /**
     144                 * The class responsible for the Spartan Gallery options metabox (native
     145                 * WordPress replacement for the previous Redux Framework panel).
     146                 */
     147                require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-spartan-gallery-options.php';
     148
     149                /**
    139150                 * The class responsible for defining all actions that occur in the admin area.
    140151                 */
    … …  
    234245                $plugin_i18n = new Spartan_Gallery_i18n();
    235246
    236                 $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
     247                $this->loader->add_action( 'init', $plugin_i18n, 'load_plugin_textdomain' );
    237248
    238249        }
  • spartan-gallery/trunk/public/class-spartan-gallery-public.php

    r3204032 r3619020  
    186186                       
    187187
    188                         // Loop through each post ID
    189                         foreach (explode(',',$get_all_post_attachements) as $post_id) {
    190                                 // Retrieve the post object by ID
    191                                 $post = get_post($post_id);
    192 
    193                                 // Check if the post exists
    194                                 if ($post) {
    195                                         // Get the GUID of the post and push it into the array
    196                                         $post_guids[] = $post;
     188                        $post_guids = array();
     189                        if ( ! empty( $get_all_post_attachements ) ) {
     190                                foreach ( explode( ',', $get_all_post_attachements ) as $post_id ) {
     191                                        $post = get_post( absint( $post_id ) );
     192                                        if ( $post ) {
     193                                                $post_guids[] = $post;
     194                                        }
    197195                                }
     196                        }
     197
     198                        if ( empty( $post_guids ) ) {
     199                                return '<!-- spartan-gallery: no images -->';
    198200                        }
    199201
  • spartan-gallery/trunk/public/css/freewall-main.css

    r2145680 r3619020  
    66}
    77
    8 .info {
    9        padding: 15px;
    10        color: #333;
    11      }
    12 
    13 
    148#freewall {
    159 top: 65px;
  • spartan-gallery/trunk/public/css/spartan-gallery-public.css

    r3204032 r3619020  
    66.container {
    77  position: relative;
    8 
    9 }
    10 
    11 .info
    12 {
    13   color: black;
    148
    159}
  • spartan-gallery/trunk/public/custom-columns.php

    r2145680 r3619020  
    7272      <tr><td>
    7373
    74       <span style="color:#183691;" ><code>[spartan_gallery  id="<code style="color:green;" ><?php print_r(get_the_ID()); ?></code>"]</code><code style="color:#A71D5D;" ></code>
     74      <span style="color:#183691;" ><code>[spartan_gallery  id="<code style="color:green;" ><?php echo absint( get_the_ID() ); ?></code>"]</code><code style="color:#A71D5D;" ></code>
    7575   </span>
    7676      </td>
  • spartan-gallery/trunk/public/html-cointainer-outputs/class-3d-slider-html-container.php

    r3204032 r3619020  
    11<?php
    22if ( ! defined( 'WPINC' ) ) {
    3 
    43    die;
    5 
    64}
    7 
    85
    96Class ThreeD_Image_Slider
    107{
     8    static function ThreeDImageSlidet_Html_container( $attachments, $gallery_id )
     9    {
     10        $CSSClass = new Spartan_Gallery_Generated_CSS_Output();
    1111
    12   static function ThreeDImageSlidet_Html_container( $attachments, $gallery_id )
    13   {
     12        $image_options_add_extra_css         = get_post_meta( $gallery_id, 'add_extra_css', true );
     13        $image_options_display_original      = get_post_meta( $gallery_id, 'display_original', true );
     14        $image_options_thumbnail_options     = get_post_meta( $gallery_id, 'thumbnail_options', true );
     15        $image_options_thumbnail_size        = get_post_meta( $gallery_id, 'thumbnail_size', true );
     16        $image_options_image_width           = absint( get_post_meta( $gallery_id, 'image_width', true ) );
     17        $image_options_image_height          = absint( get_post_meta( $gallery_id, 'image_height', true ) );
     18        $image_options_image_measure_value   = get_post_meta( $gallery_id, 'image_measure_value', true );
     19        $safe_extra_css                      = wp_strip_all_tags( $image_options_add_extra_css );
    1420
    15     $CSSClass = new Spartan_Gallery_Generated_CSS_Output();
    16     $output = '';
     21        // A gallery whose Image Options were never saved (or saved before the
     22        // options-panel slider bug was fixed) can have these stored as 0, which
     23        // renders every slide at 0px and makes the whole slider look empty.
     24        if ( ! $image_options_image_width ) {
     25            $image_options_image_width = 150;
     26        }
     27        if ( ! $image_options_image_height ) {
     28            $image_options_image_height = 150;
     29        }
    1730
    18     $image_options_add_extra_css = get_post_meta( $gallery_id , 'add_extra_css', true );
    19     $output .= '<style>'.$image_options_add_extra_css.'</style>';
    20    
    21     $output .= '<div style="'.$CSSClass->output_php_Css($gallery_id).'" class="spartan-gallery-wrapper w-gallery">';
    22       $output .= '<article id="demo-carousel" class="demo">';
    23         //$output .= '<a class="responsiveGallery-btn responsiveGallery-btn_prev" href="javascript:void(0);"></a>';
    24         //$output .= '<a class="responsiveGallery-btn responsiveGallery-btn_next" href="javascript:void(0);"></a>';
     31        $allowed_measure_values = array( 'px', '%', 'em', 'rem', 'vw', 'vh' );
     32        $image_measure_value    = in_array( $image_options_image_measure_value, $allowed_measure_values, true )
     33            ? $image_options_image_measure_value
     34            : 'px';
     35
     36        $output = '';
     37        $output .= '<style>' . $safe_extra_css . '</style>';
     38        $output .= '<div style="' . $CSSClass->output_php_Css( $gallery_id ) . '" class="spartan-gallery-wrapper w-gallery">';
     39        $output .= '<article id="demo-carousel" class="demo">';
    2540        $output .= '<div id="carousel">';
    26           $output .= '<ul class="flip-items">';
    27           if ( isset( $attachments ) && ! empty( $attachments )  )
    28           {
     41        $output .= '<ul class="flip-items">';
     42
     43        if ( isset( $attachments ) && ! empty( $attachments ) ) {
    2944            foreach ( $attachments as $attachments_id => $attachment_val ) {
    3045
    31               $img_size = array( '120', '160', '180', '240', '280', '320'   );
    32               $image_options_display_original = get_post_meta( $gallery_id , 'display_original', true ); // array
    33               $image_options_img_margin = get_post_meta( $gallery_id , 'img_margin', true );
    34               $image_options_thumbnail_options = get_post_meta( $gallery_id , 'thumbnail_options', true );
    35               $image_options_textbox_height_range = get_post_meta( $gallery_id , 'textbox_height_range', true );
    36               $image_options_display_text = get_post_meta( $gallery_id , 'display_text', true );
    37               $image_options_info_background_color = get_post_meta( $gallery_id , 'info_background_color', true );
    38               $image_options_container_font_size = get_post_meta( $gallery_id , 'container_font_size', true );
    39               $image_options_thumbnail_size = get_post_meta( $gallery_id , 'thumbnail_size', true );
    40               $image_options_image_width = get_post_meta( $gallery_id , 'image_width', true );
    41               $image_options_image_height = get_post_meta( $gallery_id , 'image_height', true );
    42               $image_options_font_family = get_post_meta( $gallery_id , 'font_family', true );
    43               $image_options_image_measure_value = get_post_meta( $gallery_id , 'image_measure_value', true );
     46                $image_attributes = wp_get_attachment_image_src( $attachment_val->ID, $image_options_thumbnail_size );
    4447
    45               $image_attributes = wp_get_attachment_image_src( $attachment_val->ID , $image_options_thumbnail_size  );
     48                $output .= '<li href="' . esc_url( $attachment_val->guid ) . '" class="js-img-viwer" data-caption="" data-id="' . absint( $attachments_id ) . '">';
    4649
    47              
     50                if ( $image_options_display_original == true and $image_options_thumbnail_options == false ) {
     51                    $output .= '<img style="height:' . $image_options_image_height . $image_measure_value . '; width:' . $image_options_image_width . $image_measure_value . '; object-fit:cover; object-position:center;" src="' . esc_url( $attachment_val->guid ) . '" />';
     52                } elseif ( $image_options_thumbnail_options == true and $image_options_display_original == false ) {
     53                    $output .= '<img style="height:' . $image_options_image_height . $image_measure_value . '; width:' . $image_options_image_width . $image_measure_value . '; object-fit:cover; object-position:center;" src="' . esc_url( $image_attributes[0] ) . '" />';
     54                } else {
     55                    $output .= '<p>' . esc_html__( 'Image Options: "Display Original" or "Display Thumbnail" must be enabled, but not both simultaneously.', 'spartan-gallery' ) . '</p>';
     56                }
    4857
    49               $output .= '<li href="'.$attachment_val->guid.'"  class="js-img-viwer " data-caption="" data-id="'.$attachments_id.'">';
     58                $output .= '</li>';
     59            }
     60        }
    5061
    51                 if ( $image_options_display_original == true and $image_options_thumbnail_options == false )
    52                 {
     62        $output .= '</ul>';
     63        $output .= '</div>';
     64        $output .= '</article>';
     65        $output .= '</div>';
    5366
    54                   //$output .= '<a href="#" class="responsivGallery-link">';
    55                     $output .= '<img style="height:'.$image_options_image_height.''.$image_options_image_measure_value.';  width:'.$image_options_image_width.''.$image_options_image_measure_value.';" src="'.$attachment_val->guid.'"  />';
    56                   //$output .= '</a>';
    57 
    58                 }
    59                 elseif ( $image_options_thumbnail_options == true and $image_options_display_original == false )
    60                 {
    61 
    62                   //$output .= '<a href="#" class="responsivGallery-link">';
    63                     $output .= '<img style="height:'.$image_options_image_height.''.$image_options_image_measure_value.';  width:'.$image_options_image_width.''.$image_options_image_measure_value.';" src="'.$image_attributes[0].'"  />';
    64                   //$output .= '</a>';
    65 
    66                 }
    67                 else
    68                 {
    69                  
    70                   $output .=  '<p>Image Options => "Display Original Size Image" or "Display Thumnail Size" settings are turned on or off same time</p>';
    71 
    72                   print $text;
    73 
    74                 }
    75                 $output .= '<div style="color: black;" class="w-responsivGallery-info">';
    76                 if ( ! empty( $attachment_id ) and true == $image_options_display_text )
    77                 {
    78 
    79 
    80                   $html .= '<div class="info" >';
    81                     if( ! empty( $attachment_val->post_title))
    82                     {
    83                       $html .= '<h5 class="text spartan-gallery-img-title" >'.$attachment_val->post_title.'</h5>';
    84                     }
    85                     if( ! empty( $attachment_val->post_content))  {
    86                       $html .= '<p class="text spartan-gallery-img-description" >'.$attachment_val->post_content.'</p>';
    87                     }
    88                    
    89                     if( ! empty( $attachment_val->guid ) ) {
    90                       $html .= ('<td colspan="3" style="background-color:#005673; text-align:right; padding: 4px 0px;">
    91                         <button class="spartan-gallery-img-button text" onclick="parent.open(\'' . $attachment_val->guid . '\')" >'.$attachment_val->post_title.'</button></td>');
    92                     }
    93                        
    94                   $html .= '</div>';
    95 
    96                 }
    97                 $output .= '</div>';
    98               $output .= '</li>';
    99 
    100             }
    101           }
    102           $output .= '</ul>';
    103           $output .= '</div>';
    104         $output .= '</article>';
    105       $output .= '</div>';
    106 
    107       $output .=
    108         '
     67        $output .= '
    10968        <script>
    11069        jQuery( document ).ready( function( $ ){
    111           var carousel = $("#carousel").flipster({
     70            var carousel = $("#carousel").flipster({
    11271                style: "carousel",
    11372                spacing: -0.2,
    114                
    115                 buttons:   true,
     73                buttons: true,
    11674            });
    117             });
     75        });
    11876        </script>';
    11977
    120       return $output;
    121 
    122 
    123 
    124 
    125   }
    126 
    127 
     78        return $output;
     79    }
    12880}
  • spartan-gallery/trunk/public/html-cointainer-outputs/class-freewall-chaotic-output.php

    r3204032 r3619020  
    11<?php
    22if ( ! defined( 'WPINC' ) ) {
    3 
    43    die;
    5 
    64}
    7 
    85
    96Class Freewall_Chaotic_Container
    107{
    11      
     8    static function display_chaotic_html_container( $attachments, $gallery_id )
     9    {
     10        $CSSClass = new Spartan_Gallery_Generated_CSS_Output();
    1211
     12        $image_options_add_extra_css         = get_post_meta( $gallery_id, 'add_extra_css', true );
     13        $image_options_display_original      = get_post_meta( $gallery_id, 'display_original', true );
     14        $image_options_img_margin            = absint( get_post_meta( $gallery_id, 'img_margin', true ) );
     15        $image_options_thumbnail_options     = get_post_meta( $gallery_id, 'thumbnail_options', true );
     16        $image_options_thumbnail_size        = get_post_meta( $gallery_id, 'thumbnail_size', true );
     17        $safe_extra_css                      = wp_strip_all_tags( $image_options_add_extra_css );
    1318
    14       static function display_chaotic_html_container( $attachments, $gallery_id )
    15       {
     19        $html = '';
     20        $html .= '<style>' . $safe_extra_css . '</style>';
     21        $html .= '<div style="' . $CSSClass->output_php_Css( $gallery_id ) . '" class="spartan-gallery-wrapper">';
     22        $html .= '<div id="freewall-chaotic" class="masonary">';
    1623
    17         $CSSClass = new Spartan_Gallery_Generated_CSS_Output();
    18                           //$CSSClass->output_php_Css($spartan_gallery_post_type['post_parent']);
    19        
    20         $html = '';
    21         $image_options_add_extra_css = get_post_meta( $gallery_id , 'add_extra_css', true );
    22         $html .= '<style>
    23         '.$image_options_add_extra_css.' 
    24                           </style>';
    25         $html .= '  <div style="'.$CSSClass->output_php_Css($gallery_id).'" class="spartan-gallery-wrapper" >';
    26           $html .= '  <div id="freewall-chaotic" class="masonary" >'; //data-fixSize="true"
    27           // Loop through them and output an image
    28             $img_size = array( '120', '160', '180', '240', '280', '320'   );
     24        $img_size = array( '120', '160', '180', '240', '280', '320' );
    2925
    30             foreach ( (array) $attachments as $attachment_id => $attachment_val ) {
    31               //Settings variables for from database
    32               $img_size = array( '120', '160', '180', '240', '280', '320'   );
    33               $image_options_display_original = get_post_meta( $gallery_id , 'display_original', true ); // array
    34               $image_options_img_margin = get_post_meta( $gallery_id , 'img_margin', true );
    35               $image_options_thumbnail_options = get_post_meta( $gallery_id , 'thumbnail_options', true );
    36               $image_options_textbox_height_range = get_post_meta( $gallery_id , 'textbox_height_range', true );
    37               $image_options_display_text = get_post_meta( $gallery_id , 'display_text', true );
    38               $image_options_info_background_color = get_post_meta( $gallery_id , 'info_background_color', true );
    39               $image_options_container_font_size = get_post_meta( $gallery_id , 'container_font_size', true );
    40               $image_options_thumbnail_size = get_post_meta( $gallery_id , 'thumbnail_size', true );
    41               $image_options_font_family = get_post_meta( $gallery_id , 'font_family', true );
    42              
    43              
    44               $image_attributes = wp_get_attachment_image_src( $attachment_val->ID , $image_options_thumbnail_size  );
    45               //print_r( $image_options_add_extra_css);
    46              
    47               if ( $image_options_display_original == true xor $image_options_thumbnail_options == true ) {
     26        foreach ( (array) $attachments as $attachment_id => $attachment_val ) {
    4827
    49                 $html .=  '<div  class="freewall-brick-chaotic brick"  data-width="'.$img_size[array_rand( $img_size , 1 )].'" data-height="'.$img_size[array_rand( $img_size , 1 )].'" data-delay="'.$attachment_id.'"   >';
    50 
    51               }
    52 
    53               $html .=  '<a  href="'.$attachment_val->guid.'"  class="js-img-viwer img-true-location" data-caption="" data-id="'.$attachment_id.'" >';
    54                   //=====================  Random width layout   =============================
    55                  
    56                   if ( $image_options_display_original == true and $image_options_thumbnail_options == false ) {
    57 
    58                     $html .= '<img class="image" style="height:100%;  width:100%;" src="'.$attachment_val->guid.'"  />';
    59                    
    60                   } elseif ( $image_options_thumbnail_options == true and $image_options_display_original == false ) {
    61 
    62                     $html .= '<img class="image" style="height:100%;  width:100%;" src="'.$image_attributes[0].'"  />';
    63 
    64                   } else
    65                   {
    66                     $text =  '<p>Image Options => "Display Original Size Image" or "Display Thumnail Size" settings are turned on or off same time</p>';
    67                     //print $text;
    68                     return $text;
    69                   }
    70 
    71 
    72                   //$s = get_post_meta( get_the_ID(),"imgtitle" . $attachment_val->ID, true );
    73 
    74                   if ( ! empty( $attachment_id ) and true == $image_options_display_text ) {
    75                       if( true == $image_options_display_text ) {
    76                           $html .= '<style>
    77                             .image
    78                             {
    79                               max-height: calc( 100% - '.$image_options_textbox_height_range.'% ) !important;
    80                             }
    81                             .info
    82                             {
    83                               max-height: calc( 100% - '.$image_options_textbox_height_range.'% ) !important;
    84                               background-color: '.$image_options_info_background_color.';
    85                               position: relative;
    86                               margin: 0px;
    87                               font-size: '.$image_options_container_font_size.'px !important ;
    88                             }
    89                            
    90                             .info>p
    91                             {
    92                               font-size: '.$image_options_font_family['font-size'].';
    93                               color:      '.$image_options_font_family['color'].';
    94                               font-style:  '.$image_options_font_family['font-style'].';
    95                               font-family: '.$image_options_font_family['font-family'] .';
    96                               line-height:  '.$image_options_font_family['line-height'].';
    97                               font-weight: '.$image_options_font_family['font-weight'].';
    98                               text-align: '.$image_options_font_family['text-align'].';
    99                             }
    100                            
    101                             .info>h5
    102                             {
    103                               font-size: '.$image_options_font_family['font-size'].';
    104                               color:      '.$image_options_font_family['color'].';
    105                               font-style:  '.$image_options_font_family['font-style'].';
    106                               font-family: '.$image_options_font_family['font-family'] .';
    107                               line-height:  '.$image_options_font_family['line-height'].';
    108                               font-weight: '.$image_options_font_family['font-weight'].';
    109                               text-align: '.$image_options_font_family['text-align'].';
    110                             }
    111 
    112                             .info>button
    113                             {
    114                               font-size: '.$image_options_font_family['font-size'].';
    115                               color:      '.$image_options_font_family['color'].';
    116                              
    117                             }
    118                             '.$image_options_add_extra_css.' 
    119                           </style>';
    120                          
    121                         }
    122 
    123                       $html .= '<div class="info" >';
    124                           if( ! empty( $attachment_val->post_title))
    125                           {
    126                             $html .= '<h5 class="text spartan-gallery-img-title" >'.$attachment_val->post_title.'</h5>';
    127                           }
    128                           if( ! empty( $attachment_val->post_content))  {
    129                             $html .= '<p class="text spartan-gallery-img-description" >'.$attachment_val->post_content.'</p>';
    130                           }
    131                          
    132                           if( ! empty( $attachment_val->guid ) ) {
    133                             $html .= ('<td colspan="3" style="background-color:#005673; text-align:right; padding: 4px 0px;">
    134                               <button class="spartan-gallery-img-button text" onclick="parent.open(\'' . $attachment_val->guid . '\')" >'.$attachment_val->post_title.'</button></td>');
    135                           }
    136                              
    137                        $html .= '</div>';
    138 
    139                     }
    140 
    141               $html .= '</a>';
    142 
    143 
     28            $image_attributes = wp_get_attachment_image_src( $attachment_val->ID, $image_options_thumbnail_size );
    14429
    14530            if ( $image_options_display_original == true xor $image_options_thumbnail_options == true ) {
    146               $html .= '</div>';
     31                $brick_w_index = array_rand( $img_size, 1 );
     32                $brick_h_index = wp_rand( max( 0, $brick_w_index - 1 ), min( count( $img_size ) - 1, $brick_w_index + 1 ) );
     33                $html .= '<div class="freewall-brick-chaotic brick" data-width="' . $img_size[ $brick_w_index ] . '" data-height="' . $img_size[ $brick_h_index ] . '" data-delay="' . absint( $attachment_id ) . '">';
    14734            }
    14835
     36            $html .= '<a href="' . esc_url( $attachment_val->guid ) . '" class="js-img-viwer img-true-location" data-caption="" data-id="' . absint( $attachment_id ) . '">';
    14937
     38            if ( $image_options_display_original == true and $image_options_thumbnail_options == false ) {
     39                $html .= '<img class="image" style="height:100%; width:100%; object-fit:cover; object-position:center;" loading="lazy" src="' . esc_url( $attachment_val->guid ) . '" />';
     40            } elseif ( $image_options_thumbnail_options == true and $image_options_display_original == false ) {
     41                $html .= '<img class="image" style="height:100%; width:100%; object-fit:cover; object-position:center;" loading="lazy" src="' . esc_url( $image_attributes[0] ) . '" />';
     42            } else {
     43                return '<p>' . esc_html__( 'Image Options: "Display Original" or "Display Thumbnail" must be enabled, but not both simultaneously.', 'spartan-gallery' ) . '</p>';
     44            }
    15045
     46            $html .= '</a>';
     47
     48            if ( $image_options_display_original == true xor $image_options_thumbnail_options == true ) {
     49                $html .= '</div>';
    15150            }
    152             $html .= '</div>';
    153           $html .= '</div>';
     51        }
    15452
    155           $html .= '';
    156           $html .= '<script>';
    157             $html .= 'jQuery( document ).ready( function( $ ){';
     53        $html .= '</div>';
     54        $html .= '</div>';
    15855
    159               // chaotic layout
    160                 $html .= '$(".freewall-brick-chaotic").each(function() {';
    161                     $html .= 'var wall = new Freewall("#freewall-chaotic");';
    162                     $html .= 'wall.reset({';
    163                         $html .= 'animate: true,';
    164                         $html .= 'cellW: 150,';
    165                         $html .= 'cellH: 150,';
    166                         //fixSize: 1,
    167                         $html .= 'gutterY: '.$image_options_img_margin.',';
    168                         $html .= 'gutterX: '.$image_options_img_margin.',';
    169                         $html .=  'onResize: function() {';
    170                             $html .= 'wall.fitWidth();';
    171                         $html .= '}';
    172                     $html .= '});';
    173                     $html .= 'wall.addCustomEvent("onBlockLoad", function(setting) {';
    174                         $html .= 'console.log(setting);';
    175                     $html .= '});';
    176                     $html .= 'wall.fitWidth();';
    177                 $html .= '});';
     56        $html .= '<script>
     57            jQuery( document ).ready( function( $ ){
     58                $(".freewall-brick-chaotic").each(function() {
     59                    var wall = new Freewall("#freewall-chaotic");
     60                    wall.reset({
     61                        animate: true,
     62                        cellW: 150,
     63                        cellH: 150,
     64                        gutterY: ' . $image_options_img_margin . ',
     65                        gutterX: ' . $image_options_img_margin . ',
     66                        onResize: function() {
     67                            wall.fitWidth();
     68                        }
     69                    });
     70                    wall.fitWidth();
     71                });
     72            });
     73        </script>';
    17874
    179             $html .= ' });';
    180             $html .= '</script>';
    181 
    182             return $html;
    183 
    184 
    185       }
    186 
    187 
    188 
    189 
     75        return $html;
     76    }
    19077}
  • spartan-gallery/trunk/public/html-cointainer-outputs/class-freewall-fixed-img-output.php

    r3204032 r3619020  
    11<?php
    22if ( ! defined( 'WPINC' ) ) {
    3 
    43    die;
    5 
    64}
    7 
    85
    96Class Freewall_Fixed_Img_Container
    107{
     8    static function display_fixed_img_container( $attachments, $gallery_id )
     9    {
     10        $CSSClass = new Spartan_Gallery_Generated_CSS_Output();
    1111
     12        $image_options_add_extra_css         = get_post_meta( $gallery_id, 'add_extra_css', true );
     13        $image_options_display_original      = get_post_meta( $gallery_id, 'display_original', true );
     14        $image_options_img_margin            = absint( get_post_meta( $gallery_id, 'img_margin', true ) );
     15        $image_options_thumbnail_options     = get_post_meta( $gallery_id, 'thumbnail_options', true );
     16        $image_options_thumbnail_size        = get_post_meta( $gallery_id, 'thumbnail_size', true );
     17        $image_options_image_width           = absint( get_post_meta( $gallery_id, 'image_width', true ) );
     18        $image_options_image_height          = absint( get_post_meta( $gallery_id, 'image_height', true ) );
     19        $safe_extra_css                      = wp_strip_all_tags( $image_options_add_extra_css );
    1220
    13       static function display_fixed_img_container( $attachments, $gallery_id   )
    14       {
    15         $CSSClass = new Spartan_Gallery_Generated_CSS_Output();
     21        // A gallery whose Image Options were never saved (or saved before the
     22        // options-panel slider bug was fixed) can have these stored as 0, which
     23        // renders zero-size bricks and makes the whole gallery look empty.
     24        if ( ! $image_options_image_width ) {
     25            $image_options_image_width = 150;
     26        }
     27        if ( ! $image_options_image_height ) {
     28            $image_options_image_height = 150;
     29        }
     30
    1631        $html = '';
    17         $image_options_add_extra_css = get_post_meta( $gallery_id , 'add_extra_css', true );
    18         $html .= '<style>'.$image_options_add_extra_css.'</style>';
    19         $html .= '  <div style="'.$CSSClass->output_php_Css($gallery_id).'" class="spartan-gallery-wrapper" >';
    20           $html .= '  <div id="freewall" class="masonary" >'; //data-fixSize="true"
    21           // Loop through them and output an image
     32        $html .= '<style>' . $safe_extra_css . '</style>';
     33        $html .= '<div style="' . $CSSClass->output_php_Css( $gallery_id ) . '" class="spartan-gallery-wrapper">';
     34        $html .= '<div id="freewall" class="masonary">';
    2235
    23             foreach ( (array) $attachments as $attachment_id => $attachment_val ) {
     36        foreach ( (array) $attachments as $attachment_id => $attachment_val ) {
    2437
    25               $img_size = array( '120', '160', '180', '240', '280', '320'   );
    26               $image_options_display_original = get_post_meta( $gallery_id , 'display_original', true ); // array
    27               $image_options_img_margin = get_post_meta( $gallery_id , 'img_margin', true );
    28               $image_options_thumbnail_options = get_post_meta( $gallery_id , 'thumbnail_options', true );
    29               $image_options_textbox_height_range = get_post_meta( $gallery_id , 'textbox_height_range', true );
    30               $image_options_display_text = get_post_meta( $gallery_id , 'display_text', true );
    31               $image_options_info_background_color = get_post_meta( $gallery_id , 'info_background_color', true );
    32               $image_options_container_font_size = get_post_meta( $gallery_id , 'container_font_size', true );
    33               $image_options_thumbnail_size = get_post_meta( $gallery_id , 'thumbnail_size', true );
    34               $image_options_image_width = get_post_meta( $gallery_id , 'image_width', true );
    35               $image_options_image_height = get_post_meta( $gallery_id , 'image_height', true );
    36               $image_options_font_family = get_post_meta( $gallery_id , 'font_family', true );
    37              
    38              
    39               $image_attributes = wp_get_attachment_image_src( $attachment_val->ID , $image_options_thumbnail_size  );
     38            $image_attributes = wp_get_attachment_image_src( $attachment_val->ID, $image_options_thumbnail_size );
    4039
    41               if ( $image_options_display_original == true xor $image_options_thumbnail_options == true )
    42               {
    43 
    44                 $html .=  '<div  class="freewall-brick brick overlay"  data-width="'.$image_options_image_width .'" data-height="'.$image_options_image_height.'" data-delay="'.$attachment_id.'"   >';
    45              
    46               }
    47 
    48               $html .=  '<a  href="'.$attachment_val->guid.'"  class="js-img-viwer img-true-location container" data-caption="" data-id="'.$attachment_id.'" >';
    49 
    50                   //=====================  Fixed Image layout   =============================
    51                   if ( $image_options_display_original == true and $image_options_thumbnail_options == false )
    52                   {
    53 
    54                     $html .= '<img class="image" style="height:100%;  width:100%;" src="'.$attachment_val->guid.'"  />';
    55 
    56                   } elseif ( $image_options_thumbnail_options == true and $image_options_display_original == false )
    57                   {
    58 
    59                     $html .= '<img class="image" style="height:100%;  width:100%;"  src="'.$image_attributes[0].'"  />';
    60 
    61                   } else
    62                   {
    63                     $text =  '<p>Image Options => "Display Original Size Image" or "Display Thumnail Size" settings are turned on or off same time</p>';
    64 
    65                     print $text;
    66                    
    67                   }
    68 
    69 
    70                   if ( ! empty( $attachment_id ) and true == $image_options_display_text ) {
    71                     if( true == $image_options_display_text ) {
    72                         $html .= '<style>
    73                           .image
    74                           {
    75                             max-height: calc( 100% - '.$image_options_textbox_height_range.'% ) !important;
    76                           }
    77                           .info
    78                           {
    79                             max-height: calc( 100% - '.$image_options_textbox_height_range.'% ) !important;
    80                             background-color: '.$image_options_info_background_color.';
    81                             position: relative;
    82                             margin: 0px;
    83                             font-size: '.$image_options_container_font_size.'px !important ;
    84                           }
    85                          
    86                           .info>p
    87                           {
    88                             font-size: '.$image_options_font_family['font-size'].';
    89                             color:      '.$image_options_font_family['color'].';
    90                             font-style:  '.$image_options_font_family['font-style'].';
    91                             font-family: '.$image_options_font_family['font-family'] .';
    92                             line-height:  '.$image_options_font_family['line-height'].';
    93                             font-weight: '.$image_options_font_family['font-weight'].';
    94                             text-align: '.$image_options_font_family['text-align'].';
    95                           }
    96                          
    97                           .info>h5
    98                           {
    99                             font-size: '.$image_options_font_family['font-size'].';
    100                             color:      '.$image_options_font_family['color'].';
    101                             font-style:  '.$image_options_font_family['font-style'].';
    102                             font-family: '.$image_options_font_family['font-family'] .';
    103                             line-height:  '.$image_options_font_family['line-height'].';
    104                             font-weight: '.$image_options_font_family['font-weight'].';
    105                             text-align: '.$image_options_font_family['text-align'].';
    106                           }
    107 
    108                           .info>button
    109                           {
    110                             font-size: '.$image_options_font_family['font-size'].';
    111                             color:      '.$image_options_font_family['color'].';
    112                            
    113                           }
    114                           '.$image_options_add_extra_css.' 
    115                         </style>';
    116                        
    117                       }
    118 
    119                     $html .= '<div class="info" >';
    120                         if( ! empty( $attachment_val->post_title))
    121                         {
    122                           $html .= '<h5 class="text spartan-gallery-img-title" >'.$attachment_val->post_title.'</h5>';
    123                         }
    124                         if( ! empty( $attachment_val->post_content))  {
    125                           $html .= '<p class="text spartan-gallery-img-description" >'.$attachment_val->post_content.'</p>';
    126                         }
    127                        
    128                         if( ! empty( $attachment_val->guid ) ) {
    129                           $html .= ('<td colspan="3" style="background-color:#005673; text-align:right; padding: 4px 0px;">
    130                             <button class="spartan-gallery-img-button text" onclick="parent.open(\'' . $attachment_val->guid . '\')" >'.$attachment_val->post_title.'</button></td>');
    131                         }
    132                            
    133                      $html .= '</div>';
    134 
    135                     }
    136 
    137               $html .= '</a>';
    138 
    139 
    140 
    141             if ( $image_options_display_original == true xor $image_options_thumbnail_options == true )
    142             {
    143               $html .= '</div>';
     40            if ( $image_options_display_original == true xor $image_options_thumbnail_options == true ) {
     41                $html .= '<div class="freewall-brick brick overlay" data-width="' . $image_options_image_width . '" data-height="' . $image_options_image_height . '" data-delay="' . absint( $attachment_id ) . '">';
    14442            }
    14543
     44            $html .= '<a href="' . esc_url( $attachment_val->guid ) . '" class="js-img-viwer img-true-location container" data-caption="" data-id="' . absint( $attachment_id ) . '">';
    14645
     46            if ( $image_options_display_original == true and $image_options_thumbnail_options == false ) {
     47                $html .= '<img class="image" style="height:100%; width:100%; object-fit:cover; object-position:center;" loading="lazy" src="' . esc_url( $attachment_val->guid ) . '" />';
     48            } elseif ( $image_options_thumbnail_options == true and $image_options_display_original == false ) {
     49                $html .= '<img class="image" style="height:100%; width:100%; object-fit:cover; object-position:center;" loading="lazy" src="' . esc_url( $image_attributes[0] ) . '" />';
     50            } else {
     51                return '<p>' . esc_html__( 'Image Options: "Display Original" or "Display Thumbnail" must be enabled, but not both simultaneously.', 'spartan-gallery' ) . '</p>';
    14752            }
    148             $html .= '</div>';
    149           $html .= '</div>';
    15053
     54            $html .= '</a>';
    15155
     56            if ( $image_options_display_original == true xor $image_options_thumbnail_options == true ) {
     57                $html .= '</div>';
     58            }
     59        }
    15260
    153           $html .= '';
    154           $html .= '<script>';
    155             $html .= 'jQuery( document ).ready( function( $ ){';
     61        $html .= '</div>';
     62        $html .= '</div>';
    15663
    157               // chaotic layout
    158                 $html .= '$(".freewall-brick").each(function() {';
    159                     $html .= 'var wall = new Freewall("#freewall");';
    160                     $html .= 'wall.reset({';
    161                         $html .= 'animate: true,';
    162                         //$script .='cellW: 100,';
    163                         //$script .='cellH: 100,';
    164                         //fixSize: 1,
    165                         $html .= 'gutterY: '.$image_options_img_margin.',';
    166                         $html .= 'gutterX: '.$image_options_img_margin.',';
    167                         $html .= 'onResize: function() {';
    168                             $html .= 'wall.fitWidth();';
    169                         $html .= '}';
    170                     $html .= '});';
    171                     $html .=  'wall.addCustomEvent("onBlockLoad", function(setting) {';
    172                         $html .= 'console.log(setting);';
    173                     $html .= '});';
    174                     $html .= 'wall.fitWidth();';
    175                 $html .= '});';
     64        $html .= '<script>';
     65        $html .= 'jQuery( document ).ready( function( $ ){';
     66        $html .= '$(".freewall-brick").each(function() {';
     67        $html .= 'var wall = new Freewall("#freewall");';
     68        $html .= 'wall.reset({';
     69        $html .= 'animate: true,';
     70        $html .= 'gutterY: ' . $image_options_img_margin . ',';
     71        $html .= 'gutterX: ' . $image_options_img_margin . ',';
     72        $html .= 'onResize: function() {';
     73        $html .= 'wall.fitWidth();';
     74        $html .= '}';
     75        $html .= '});';
     76        $html .= 'wall.fitWidth();';
     77        $html .= '});';
     78        $html .= '});';
     79        $html .= '</script>';
    17680
    177             $html .= ' });';
    178 
    179            $html .= '</script>';
    180 
    181            return $html;
    182       }
    183 
    184 
    185 
     81        return $html;
     82    }
    18683}
  • spartan-gallery/trunk/public/html-cointainer-outputs/class-freewall-pinterest-output.php

    r3204032 r3619020  
    11<?php
    22if ( ! defined( 'WPINC' ) ) {
    3 
    43    die;
    5 
    64}
    7 
    85
    96Class Freewall_Pinterest_Container
    107{
    11 
    12       static function display_pinterest_container( $attachments , $gallery_id )
    13       {
     8    static function display_pinterest_container( $attachments, $gallery_id )
     9    {
    1410        $CSSClass = new Spartan_Gallery_Generated_CSS_Output();
    1511
     12        $image_options_add_extra_css         = get_post_meta( $gallery_id, 'add_extra_css', true );
     13        $image_options_display_original      = get_post_meta( $gallery_id, 'display_original', true );
     14        $image_options_img_margin            = absint( get_post_meta( $gallery_id, 'img_margin', true ) );
     15        $image_options_thumbnail_options     = get_post_meta( $gallery_id, 'thumbnail_options', true );
     16        $image_options_thumbnail_size        = get_post_meta( $gallery_id, 'thumbnail_size', true );
     17        $safe_extra_css                      = wp_strip_all_tags( $image_options_add_extra_css );
     18
    1619        $html = '';
     20        $html .= '<style>' . $safe_extra_css . '</style>';
     21        $html .= '<div style="' . $CSSClass->output_php_Css( $gallery_id ) . '" class="spartan-gallery-wrapper">';
     22        $html .= '<div id="freewall-pinterest" class="masonary">';
    1723
    18         $image_options_add_extra_css = get_post_meta( $gallery_id , 'add_extra_css', true );
    19         $html .= '<style>'.$image_options_add_extra_css.'</style>';
     24        $img_size = array( '120', '160', '180', '240', '280', '320' );
    2025
    21         $html .= '  <div style="'.$CSSClass->output_php_Css($gallery_id).'" class="spartan-gallery-wrapper" >';
    22           $html .= '  <div id="freewall-pinterest" class="masonary" >'; //data-fixSize="true"
    23           // Loop through them and output an image
    24             $img_size = array( '120', '160', '180', '240', '280', '320'   );
     26        foreach ( (array) $attachments as $attachment_id => $attachment_val ) {
    2527
    26             foreach ( (array) $attachments as $attachment_id => $attachment_val ) {
     28            $image_attributes = wp_get_attachment_image_src( $attachment_val->ID, $image_options_thumbnail_size );
    2729
    28                 $img_size = array( '120', '160', '180', '240', '280', '320'   );
    29                 //Settings variables for from database
    30                
    31                 $image_options_display_original = get_post_meta( $gallery_id , 'display_original', true ); // array
    32                 $image_options_img_margin = get_post_meta( $gallery_id , 'img_margin', true );
    33                 $image_options_thumbnail_options = get_post_meta( $gallery_id , 'thumbnail_options', true );
    34                 $image_options_textbox_height_range = get_post_meta( $gallery_id , 'textbox_height_range', true );
    35                 $image_options_display_text = get_post_meta( $gallery_id , 'display_text', true );
    36                 $image_options_info_background_color = get_post_meta( $gallery_id , 'info_background_color', true );
    37                 $image_options_container_font_size = get_post_meta( $gallery_id , 'container_font_size', true );
    38                 $image_options_thumbnail_size = get_post_meta( $gallery_id , 'thumbnail_size', true );
    39                 $image_options_font_family = get_post_meta( $gallery_id , 'font_family', true );
    40              
    41              
    42                 $image_attributes = wp_get_attachment_image_src( $attachment_val->ID , $image_options_thumbnail_size  );
    43 
    44                 if ( $image_options_display_original == true xor $image_options_thumbnail_options == true )
    45                 {
    46                  
    47                   $html .=  '<div  class="freewall-brick-pinterest brick"  data-width="'.$img_size[array_rand( $img_size , 1 )].'" data-height="'.$img_size[array_rand( $img_size , 1 )].'" data-delay="'.$attachment_id.'"   >';
    48                
    49                 }
    50 
    51                 $html .=  '<a  href="'.$attachment_val->guid.'"  class="js-img-viwer img-true-location" data-caption="" data-id="'.$attachment_id.'" >';
    52                     //=====================    PINTEREST lAYOUT   =============================
    53                     if ( $image_options_display_original == true and $image_options_thumbnail_options == false )
    54                     {
    55 
    56                       $html .= '<img class="image" style="height:100%;  width:100%;" src="'.$attachment_val->guid.'"  />';
    57 
    58                     }
    59                     elseif ( $image_options_thumbnail_options == true and $image_options_display_original == false )
    60                     {
    61                      
    62                       $html .= '<img class="image" style="height:100%;  width:100%;"  src="'.$image_attributes[0].'"  />';
    63 
    64                     }
    65                     else
    66                     {
    67 
    68                       $text =  '<p>Image Options => "Display Original Size Image" or "Display Thumnail Size" settings are turned on or off same time</p>';
    69 
    70                       print $text;
    71                      
    72                     }
    73 
    74 
    75                  
    76 
    77                     if ( ! empty( $attachment_id ) and true == $image_options_display_text )
    78                     {
    79 
    80 
    81                       $html .= '<div class="info" >';
    82                         if( ! empty( $attachment_val->post_title))
    83                         {
    84                           $html .= '<h5 class="text spartan-gallery-img-title" >'.$attachment_val->post_title.'</h5>';
    85                         }
    86                         if( ! empty( $attachment_val->post_content))  {
    87                           $html .= '<p class="text spartan-gallery-img-description" >'.$attachment_val->post_content.'</p>';
    88                         }
    89                        
    90                         if( ! empty( $attachment_val->guid ) ) {
    91                           $html .= ('<td colspan="3" style="background-color:#005673; text-align:right; padding: 4px 0px;">
    92                             <button class="spartan-gallery-img-button text" onclick="parent.open(\'' . $attachment_val->guid . '\')" >'.$attachment_val->post_title.'</button></td>');
    93                         }
    94                            
    95                       $html .= '</div>';
    96 
    97                     }
    98 
    99                 $html .= '</a>';
    100 
    101 
    102 
    103               if ( $image_options_display_original == true xor $image_options_thumbnail_options == true ) {
    104                 $html .= '</div>';
    105               }
    106 
    107 
     30            if ( $image_options_display_original == true xor $image_options_thumbnail_options == true ) {
     31                $brick_w_index = array_rand( $img_size, 1 );
     32                $brick_h_index = wp_rand( max( 0, $brick_w_index - 1 ), min( count( $img_size ) - 1, $brick_w_index + 1 ) );
     33                $html .= '<div class="freewall-brick-pinterest brick" data-width="' . $img_size[ $brick_w_index ] . '" data-height="' . $img_size[ $brick_h_index ] . '" data-delay="' . absint( $attachment_id ) . '">';
    10834            }
    10935
    110             if( true == $image_options_display_text ) {
    111               $html .= '<style>
    112                 .image
    113                 {
    114                   max-height: calc( 100% - '.$image_options_textbox_height_range.'% ) !important;
    115                 }
    116                 .info
    117                 {
    118                   max-height: calc( 100% - '.$image_options_textbox_height_range.'% ) !important;
    119                   background-color: '.$image_options_info_background_color.';
    120                   position: relative;
    121                   margin: 0px;
    122                   font-size: '.$image_options_container_font_size.'px !important ;
    123                 }
    124                
    125                 .info>p
    126                 {
    127                   font-size: '.$image_options_font_family['font-size'].';
    128                   color:      '.$image_options_font_family['color'].';
    129                   font-style:  '.$image_options_font_family['font-style'].';
    130                   font-family: '.$image_options_font_family['font-family'] .';
    131                   line-height:  '.$image_options_font_family['line-height'].';
    132                   font-weight: '.$image_options_font_family['font-weight'].';
    133                   text-align: '.$image_options_font_family['text-align'].';
    134                 }
    135                
    136                 .info>h5
    137                 {
    138                   font-size: '.$image_options_font_family['font-size'].';
    139                   color:      '.$image_options_font_family['color'].';
    140                   font-style:  '.$image_options_font_family['font-style'].';
    141                   font-family: '.$image_options_font_family['font-family'] .';
    142                   line-height:  '.$image_options_font_family['line-height'].';
    143                   font-weight: '.$image_options_font_family['font-weight'].';
    144                   text-align: '.$image_options_font_family['text-align'].';
    145                 }
     36            $html .= '<a href="' . esc_url( $attachment_val->guid ) . '" class="js-img-viwer img-true-location" data-caption="" data-id="' . absint( $attachment_id ) . '">';
    14637
    147                 .info>button
    148                 {
    149                   font-size: '.$image_options_font_family['font-size'].';
    150                   color:      '.$image_options_font_family['color'].';
    151                  
    152                 }
    153                 '.$image_options_add_extra_css.' 
    154               </style>';
    155              
     38            if ( $image_options_display_original == true and $image_options_thumbnail_options == false ) {
     39                $html .= '<img class="image" style="height:100%; width:100%; object-fit:cover; object-position:center;" loading="lazy" src="' . esc_url( $attachment_val->guid ) . '" />';
     40            } elseif ( $image_options_thumbnail_options == true and $image_options_display_original == false ) {
     41                $html .= '<img class="image" style="height:100%; width:100%; object-fit:cover; object-position:center;" loading="lazy" src="' . esc_url( $image_attributes[0] ) . '" />';
     42            } else {
     43                return '<p>' . esc_html__( 'Image Options: "Display Original" or "Display Thumbnail" must be enabled, but not both simultaneously.', 'spartan-gallery' ) . '</p>';
    15644            }
    157             $html .= '</div>';
    158           $html .= '</div>';
    15945
     46            $html .= '</a>';
    16047
    161           $html .= '
     48            if ( $image_options_display_original == true xor $image_options_thumbnail_options == true ) {
     49                $html .= '</div>';
     50            }
     51        }
     52
     53        $html .= '</div>';
     54        $html .= '</div>';
     55
     56        $html .= '
    16257            <script>
    16358                jQuery( document ).ready( function( $ ){
    164                 // Random width layout
    165                   var Imagewall = new Freewall("#freewall-pinterest");
    166                   Imagewall.reset({
    167                     selector: ".freewall-brick-pinterest",
    168                     animate: false,
    169                     cellW: 300,
    170                     cellH: "auto",
    171                     gutterY: '.$image_options_img_margin.',
    172                     gutterX: '.$image_options_img_margin.',
    173                     onResize: function() {
    174                       Imagewall.fitWidth();
    175                     }
    176                   });
    177                   $( document ).ready(function() {
    178                   Imagewall.fitWidth();
    179 
    180                   });
     59                    var Imagewall = new Freewall("#freewall-pinterest");
     60                    Imagewall.reset({
     61                        selector: ".freewall-brick-pinterest",
     62                        animate: false,
     63                        cellW: 300,
     64                        cellH: "auto",
     65                        gutterY: ' . $image_options_img_margin . ',
     66                        gutterX: ' . $image_options_img_margin . ',
     67                        onResize: function() {
     68                            Imagewall.fitWidth();
     69                        }
     70                    });
     71                    $( document ).ready(function() {
     72                        Imagewall.fitWidth();
     73                    });
    18174                });
    18275            </script>';
    18376
    184             return $html;
    185 
    186       }
    187 
    188 
    189 /*
    190       static function init_freewall_random_javascript()
    191       {
    192         $html .= '';
    193         $html .= '<script>';
    194           $html .= 'jQuery( document ).ready( function( $ ){';
    195             $html .= '$(".freewall-brick").each(function() {';
    196               $html .= 'var wall = new Freewall("#freewall");';
    197                 $html .= 'wall.reset({';
    198                   $html .= 'selector: "".brick",';
    199                   $html .= 'animate: true,';
    200                   $html .= 'cellW: 240,';
    201                   $html .= 'cellH: "auto",';
    202                   $html .= 'gutterY: 20,';
    203                   $html .= 'gutterX: 20,';
    204                   $html .= 'onResize: function() {';
    205                   $html .= 'wall.fitWidth();';
    206                   $html .= '}';
    207                   $html .= '});';
    208 
    209                   $html .= 'wall.container.find(".brick img").load(function() {';
    210                   $html .= 'wall.fitWidth();';
    211                 $html .= '});';
    212             $html .= '});';
    213           $html .= '});';
    214         $html .= '</script>';
    215 
    216         return  $html;
    217 
    218         //print_r( $script );
    219       }
    220 */
    221 
    222 
    223 
    224 
     77        return $html;
     78    }
    22579}
  • spartan-gallery/trunk/public/html-cointainer-outputs/class-freewall-random-output.php

    r3204032 r3619020  
    11<?php
    22if ( ! defined( 'WPINC' ) ) {
    3 
    43    die;
    5 
    64}
    7 
    85
    96Class Freewall_Random_Container
    107{
    11 
    12 
    13       static function display_random_container( $attachments, $gallery_id  )
    14       {
    15 
     8    static function display_random_container( $attachments, $gallery_id )
     9    {
    1610        $CSSClass = new Spartan_Gallery_Generated_CSS_Output();
    1711
     12        $image_options_add_extra_css         = get_post_meta( $gallery_id, 'add_extra_css', true );
     13        $image_options_display_original      = get_post_meta( $gallery_id, 'display_original', true );
     14        $image_options_img_margin            = absint( get_post_meta( $gallery_id, 'img_margin', true ) );
     15        $image_options_thumbnail_options     = get_post_meta( $gallery_id, 'thumbnail_options', true );
     16        $image_options_thumbnail_size        = get_post_meta( $gallery_id, 'thumbnail_size', true );
     17        $safe_extra_css                      = wp_strip_all_tags( $image_options_add_extra_css );
     18
    1819        $html = '';
    19         $image_options_add_extra_css = get_post_meta( $gallery_id , 'add_extra_css', true );
    20         $html .= '<style>'.$image_options_add_extra_css.'</style>';
    21          
    22         $html .=  '  <div style="'.$CSSClass->output_php_Css($gallery_id).'" class="spartan-gallery-wrapper" >';
    23           $html .= '  <div id="freewall-random" class="masonary" >'; //data-fixSize="true"
    24           // Loop through them and output an image
    25             $img_size = array( '120', '160', '180', '240', '280', '320'   );
     20        $html .= '<style>' . $safe_extra_css . '</style>';
     21        $html .= '<div style="' . $CSSClass->output_php_Css( $gallery_id ) . '" class="spartan-gallery-wrapper">';
     22        $html .= '<div id="freewall-random" class="masonary">';
    2623
    27             foreach ( (array) $attachments as $attachment_id => $attachment_val ) {
     24        $img_size = array( '120', '160', '180', '240', '280', '320' );
    2825
    29                 $img_size = array( '120', '160', '180', '240', '280', '320'   );
    30                 //Settings variables for from database
    31                
    32                 $image_options_display_original = get_post_meta( $gallery_id , 'display_original', true ); // array
    33                 $image_options_img_margin = get_post_meta( $gallery_id , 'img_margin', true );
    34                 $image_options_thumbnail_options = get_post_meta( $gallery_id , 'thumbnail_options', true );
    35                 $image_options_textbox_height_range = get_post_meta( $gallery_id , 'textbox_height_range', true );
    36                 $image_options_display_text = get_post_meta( $gallery_id , 'display_text', true );
    37                 $image_options_info_background_color = get_post_meta( $gallery_id , 'info_background_color', true );
    38                 $image_options_container_font_size = get_post_meta( $gallery_id , 'container_font_size', true );
    39                 $image_options_thumbnail_size = get_post_meta( $gallery_id , 'thumbnail_size', true );
    40                 $image_options_font_family = get_post_meta( $gallery_id , 'font_family', true );
    41              
    42              
    43                 $image_attributes = wp_get_attachment_image_src( $attachment_val->ID , $image_options_thumbnail_size  );
     26        foreach ( (array) $attachments as $attachment_id => $attachment_val ) {
    4427
    45                 if ( $image_options_display_original == true xor $image_options_thumbnail_options == true ) {
    46                   $html .=  '<div  class="freewall-brick brick"  data-width="'.$img_size[array_rand( $img_size , 1 )].'" data-height="'.$img_size[array_rand( $img_size , 1 )].'" data-delay="'.$attachment_id.'"   >';
    47                 }
     28            $image_attributes = wp_get_attachment_image_src( $attachment_val->ID, $image_options_thumbnail_size );
    4829
    49                 $html .=  '<a  href="'.$attachment_val->guid.'"  class="js-img-viwer img-true-location" data-caption="" data-id="'.$attachment_id.'" >';
    50                     //=====================  Random width layout   =============================
    51                     if ( $image_options_display_original == true and $image_options_thumbnail_options == false ) {
     30            if ( $image_options_display_original == true xor $image_options_thumbnail_options == true ) {
     31                $html .= '<div class="freewall-brick brick" data-width="' . $img_size[ array_rand( $img_size, 1 ) ] . '" data-height="' . $img_size[ array_rand( $img_size, 1 ) ] . '" data-delay="' . absint( $attachment_id ) . '">';
     32            }
    5233
    53                       $html .= '<img class="image" style="height:240px;  width:100%;" src="'.$attachment_val->guid.'"  />';
     34            $html .= '<a href="' . esc_url( $attachment_val->guid ) . '" class="js-img-viwer img-true-location" data-caption="" data-id="' . absint( $attachment_id ) . '">';
    5435
    55                     } elseif ( $image_options_thumbnail_options == true and $image_options_display_original == false ) {
     36            if ( $image_options_display_original == true and $image_options_thumbnail_options == false ) {
     37                $html .= '<img class="image" style="height:240px; width:100%; object-fit:cover; object-position:center;" loading="lazy" src="' . esc_url( $attachment_val->guid ) . '" />';
     38            } elseif ( $image_options_thumbnail_options == true and $image_options_display_original == false ) {
     39                $html .= '<img style="height:240px; width:100%; object-fit:cover; object-position:center;" loading="lazy" src="' . esc_url( $image_attributes[0] ) . '" />';
     40            } else {
     41                return '<p>' . esc_html__( 'Image Options: "Display Original" or "Display Thumbnail" must be enabled, but not both simultaneously.', 'spartan-gallery' ) . '</p>';
     42            }
    5643
    57                       $html .= '<img style="height:240px;  width:100%;" src="'.$image_attributes[0].'"  />';
     44            $html .= '</a>';
    5845
    59                     } else
    60                     {
    61                       $text =  '<p>Image Options => "Display Original Size Image" or "Display Thumnail Size" settings are turned on or off same time</p>';
    62                       print $text;
    63                       //return;
    64                     }
     46            if ( $image_options_display_original == true xor $image_options_thumbnail_options == true ) {
     47                $html .= '</div>';
     48            }
     49        }
    6550
    66                    
     51        $html .= '</div>';
     52        $html .= '</div>';
    6753
    68                     if ( ! empty( $attachment_id ) and true == $image_options_display_text ) {
    69                       if( true == $image_options_display_text ) {
    70                           $html .= '<style>
    71                             .image
    72                             {
    73                               max-height: calc( 100% - '.$image_options_textbox_height_range.'% ) !important;
    74                             }
    75                             .info
    76                             {
    77                               max-height: calc( 100% - '.$image_options_textbox_height_range.'% ) !important;
    78                               background-color: '.$image_options_info_background_color.';
    79                               position: relative;
    80                               margin: 0px;
    81                               font-size: '.$image_options_container_font_size.'px !important ;
    82                             }
    83                            
    84                             .info>p
    85                             {
    86                               font-size: '.$image_options_font_family['font-size'].';
    87                               color:      '.$image_options_font_family['color'].';
    88                               font-style:  '.$image_options_font_family['font-style'].';
    89                               font-family: '.$image_options_font_family['font-family'] .';
    90                               line-height:  '.$image_options_font_family['line-height'].';
    91                               font-weight: '.$image_options_font_family['font-weight'].';
    92                               text-align: '.$image_options_font_family['text-align'].';
    93                             }
    94                            
    95                             .info>h5
    96                             {
    97                               font-size: '.$image_options_font_family['font-size'].';
    98                               color:      '.$image_options_font_family['color'].';
    99                               font-style:  '.$image_options_font_family['font-style'].';
    100                               font-family: '.$image_options_font_family['font-family'] .';
    101                               line-height:  '.$image_options_font_family['line-height'].';
    102                               font-weight: '.$image_options_font_family['font-weight'].';
    103                               text-align: '.$image_options_font_family['text-align'].';
    104                             }
    105 
    106                             .info>button
    107                             {
    108                               font-size: '.$image_options_font_family['font-size'].';
    109                               color:      '.$image_options_font_family['color'].';
    110                              
    111                             }
    112                             '.$image_options_add_extra_css.' 
    113                           </style>';
    114                          
    115                         }
    116 
    117                       $html .= '<div class="info" >';
    118                           if( ! empty( $attachment_val->post_title))
    119                           {
    120                             $html .= '<h5 class="text spartan-gallery-img-title" >'.$attachment_val->post_title.'</h5>';
    121                           }
    122                           if( ! empty( $attachment_val->post_content))  {
    123                             $html .= '<p class="text spartan-gallery-img-description" >'.$attachment_val->post_content.'</p>';
    124                           }
    125                          
    126                           if( ! empty( $attachment_val->guid ) ) {
    127                             $html .= ('<td colspan="3" style="background-color:#005673; text-align:right; padding: 4px 0px;">
    128                               <button class="spartan-gallery-img-button text" onclick="parent.open(\'' . $attachment_val->guid . '\')" >'.$attachment_val->post_title.'</button></td>');
    129                           }
    130                              
    131                        $html .= '</div>';
    132 
    133                       }
    134 
    135                 $html .= '</a>';
    136 
    137 
    138 
    139               if ( $image_options_display_original == true xor $image_options_thumbnail_options == true ) {
    140                 $html .= '</div>';
    141               }
    142 
    143 
    144 
    145             }
    146             $html .= '</div>';
    147           $html .= '</div>';
    148 
    149 
    150 
    151 
    152           $html .= '
    153               <script>
    154                   jQuery( document ).ready( function( $ ){
    155                   // Random width layout
     54        $html .= '
     55            <script>
     56                jQuery( document ).ready( function( $ ){
    15657                    var Imagewall = new Freewall("#freewall-random");
    15758                    Imagewall.reset({
    158                       selector: ".freewall-brick",
    159                       animate: true,
    160                       cellW: 200,
    161                       cellH: "auto",
    162                       gutterY: '.$image_options_img_margin.',
    163                       gutterX: '.$image_options_img_margin.',
    164                       onResize: function() {
    165                         Imagewall.fitWidth();
    166                       }
     59                        selector: ".freewall-brick",
     60                        animate: true,
     61                        cellW: 200,
     62                        cellH: "auto",
     63                        gutterY: ' . $image_options_img_margin . ',
     64                        gutterX: ' . $image_options_img_margin . ',
     65                        onResize: function() {
     66                            Imagewall.fitWidth();
     67                        }
    16768                    });
    16869                    $( document ).ready(function() {
    169                     Imagewall.fitWidth();
     70                        Imagewall.fitWidth();
     71                    });
     72                });
     73            </script>';
    17074
    171                     });
    172                   });
    173               </script>';
    174 
    175           return $html;
    176 
    177       }
    178 
    179 
    180 
    181 
     75        return $html;
     76    }
    18277}
  • spartan-gallery/trunk/public/html-cointainer-outputs/class-hexagon-html-container.php

    r3204032 r3619020  
    11<?php
    22if ( ! defined( 'WPINC' ) ) {
    3 
    43    die;
    5 
    64}
    75
     6Class Spartan_Gallery_Hexagon
     7{
     8    static function hexagon_html_container( $attachments, $gallery_id )
     9    {
     10        $CSSClass = new Spartan_Gallery_Generated_CSS_Output();
    811
    9 Class Spartan_Gallery_Hexagon {
     12        $image_options_add_extra_css         = get_post_meta( $gallery_id, 'add_extra_css', true );
     13        $image_options_display_original      = get_post_meta( $gallery_id, 'display_original', true );
     14        $image_options_thumbnail_options     = get_post_meta( $gallery_id, 'thumbnail_options', true );
     15        $image_options_thumbnail_size        = get_post_meta( $gallery_id, 'thumbnail_size', true );
     16        $safe_extra_css                      = wp_strip_all_tags( $image_options_add_extra_css );
    1017
     18        $output = '';
     19        $output .= '<style>' . $safe_extra_css . '</style>';
     20        $output .= '<div style="' . $CSSClass->output_php_Css( $gallery_id ) . '" class="spartan-gallery-wrapper" style="position: relative; width: 100%;">';
     21        $output .= '<div class="masonary">';
     22        $output .= '<ul>';
    1123
    12   static function hexagon_html_container( $attachments, $gallery_id ) {
     24        foreach ( $attachments as $attachments_id => $attachments_val ) {
    1325
    14     $CSSClass = new Spartan_Gallery_Generated_CSS_Output();
    15     $output = '';
     26            $image_attributes = wp_get_attachment_image_src( $attachments_val->ID, $image_options_thumbnail_size );
    1627
    17     $image_options_add_extra_css = get_post_meta( $gallery_id , 'add_extra_css', true );
    18     $output  .= '<style>'.$image_options_add_extra_css.'</style>';
     28            $output .= '<li class="hex">';
     29            $output .= '<a class="js-img-viwer hexIn" data-caption="Title" data-id="' . absint( $attachments_id ) . '" href="' . esc_url( $attachments_val->guid ) . '">';
    1930
    20     $output .= '<div style="'.$CSSClass->output_php_Css($gallery_id).'" class="spartan-gallery-wrapper" style="position: relative;width: 100%;" >';
    21       $output .= '<div class="masonary" >';
    22         $output .= '<ul>';
    23           foreach ( $attachments as $attachments_id => $attachments_val ) {
    24                 $img_size = array( '120', '160', '180', '240', '280', '320'   );
    25                 //Settings variables for from database
    26                
    27                 $image_options_display_original = get_post_meta( $gallery_id , 'display_original', true ); // array
    28                 $image_options_img_margin = get_post_meta( $gallery_id , 'img_margin', true );
    29                 $image_options_thumbnail_options = get_post_meta( $gallery_id , 'thumbnail_options', true );
    30                 $image_options_textbox_height_range = get_post_meta( $gallery_id , 'textbox_height_range', true );
    31                 $image_options_display_text = get_post_meta( $gallery_id , 'display_text', true );
    32                 $image_options_info_background_color = get_post_meta( $gallery_id , 'info_background_color', true );
    33                 $image_options_container_font_size = get_post_meta( $gallery_id , 'container_font_size', true );
    34                 $image_options_thumbnail_size = get_post_meta( $gallery_id , 'thumbnail_size', true );
    35                 $image_options_font_family = get_post_meta( $gallery_id , 'font_family', true );
    36              
    37              
    38                 $image_attributes = wp_get_attachment_image_src( $attachments_val->ID , $image_options_thumbnail_size  );
    39                 //print_r($attachment_val);
     31            if ( $image_options_display_original == true and $image_options_thumbnail_options == false ) {
     32                $output .= '<img style="height:100%; width:100%; object-fit:cover; object-position:center;" loading="lazy" src="' . esc_url( $attachments_val->guid ) . '" />';
     33            } elseif ( $image_options_thumbnail_options == true and $image_options_display_original == false ) {
     34                $output .= '<img style="height:100%; width:100%; object-fit:cover; object-position:center;" loading="lazy" src="' . esc_url( $image_attributes[0] ) . '" />';
     35            } else {
     36                $output .= '<p>' . esc_html__( 'Image Options: "Display Original" or "Display Thumbnail" must be enabled, but not both simultaneously.', 'spartan-gallery' ) . '</p>';
     37            }
    4038
    41                 $output .=  '<li class="hex">';
    42                   $output .=    '<a class="js-img-viwer hexIn" data-caption="Title" data-id="'.$attachments_id.'" href="'.$attachments_val->guid.'">';
     39            $output .= '</a>';
     40            $output .= '</li>';
     41        }
    4342
    44                           if ( $image_options_display_original == true and $image_options_thumbnail_options == false ) {
     43        $output .= '</ul>';
     44        $output .= '</div>';
     45        $output .= '</div>';
    4546
    46                             $output .= '<img style="height:100%;  width:100%;" src="'.$attachments_val->guid.'"  />';
    47 
    48                           } elseif ( $image_options_thumbnail_options == true and $image_options_display_original == false ) {
    49 
    50                             $output .= '<img style="height:100%;  width:100%;" src="'.$image_attributes[0].'"  />';
    51 
    52                           } else
    53                           {
    54                             $output .=  '<p>Image Options => "Display Original Size Image" or "Display Thumnail Size" settings are turned on or off same time</p>';
    55 
    56                           }
    57 
    58 
    59                           if ( ! empty( $attachment_id ) and true == $image_options_display_text )
    60                           {
    61 
    62 
    63                             $html .= '<div class="info" >';
    64                               if( ! empty( $attachment_val->post_title))
    65                               {
    66                                 $html .= '<h5 class="text spartan-gallery-img-title" >'.$attachment_val->post_title.'</h5>';
    67                               }
    68                               if( ! empty( $attachment_val->post_content))  {
    69                                 $html .= '<p class="text spartan-gallery-img-description" >'.$attachment_val->post_content.'</p>';
    70                               }
    71                              
    72                               if( ! empty( $attachment_val->guid ) ) {
    73                                 $html .= ('<td colspan="3" style="background-color:#005673; text-align:right; padding: 4px 0px;">
    74                                   <button class="spartan-gallery-img-button text" onclick="parent.open(\'' . $attachment_val->guid . '\')" >'.$attachment_val->post_title.'</button></td>');
    75                               }
    76                                  
    77                             $html .= '</div>';
    78 
    79                           }
    80 
    81                       $output .= '</a>';
    82                   $output .= '</li>';
    83             }
    84           $output .= '</ul>';
    85         $output .= '</div>';
    86         $output .= '<script>';
    87         $output .= '';
    88 
    89 
    90         $output .= '</script>';
    91       $output .= '</div>';
    92 
    93     return $output;
    94 
     47        return $output;
    9548    }
    9649}
  • spartan-gallery/trunk/public/popup.php

    r2145680 r3619020  
    1212        exit( 'Direct script access denied.' );
    1313}
    14 /**
    15 * Image gallerry button
    16 *
    17 * @since Spartan Gallery 1.0.2
    18 *
    19 * @param array  $urls           URLs to print for resource hints.
    20 * @param string $relation_type  The relation type the URLs are printed.
    21 * @return array $urls           URLs to print for resource hints.
    22 */
    2314
    2415function button_url_get_meta( $value ) {
    … …  
    3324}
    3425
    35 
    36 /**
    37 * Image gallerry button
    38 *
    39 * @since Spartan Gallery 1.0.2
    40 *
    41 * @param array  $urls           URLs to print for resource hints.
    42 * @param string $relation_type  The relation type the URLs are printed.
    43 * @return array $urls           URLs to print for resource hints.
    44 */
    45 
    4626function button_url_add_meta_box() {
    4727        add_meta_box(
    4828                'button_url-button-url',
    49                 __( 'b', 'button_url' ),
     29                __( 'Image Button Links', 'spartan-gallery' ),
    5030                'button_url_html',
    5131                'spartan_gallery_type',
    … …  
    5636add_action( 'add_meta_boxes', 'button_url_add_meta_box' );
    5737
    58 
    59 
    60 /**
    61 * Image gallerry button
    62 *
    63 * @since Spartan Gallery 1.0.2
    64 *
    65 * @param array  $urls           URLs to print for resource hints.
    66 * @param string $relation_type  The relation type the URLs are printed.
    67 * @return array $urls           URLs to print for resource hints.
    68 */
    69 function button_url_html( $post) {
     38function button_url_html( $post ) {
    7039        wp_nonce_field( '_button_url_nonce', 'button_url_nonce' );
    71 
    7240
    7341        $args = array(
    7442                'post_type'   => 'attachment',
    7543                'numberposts' => -1,
    76                 //'post_parent' => $page_id,
    7744                'post_status' => null,
    7845                'meta_query'  => array(
    … …  
    8249                        )
    8350                )
    84 
    8551        );
    8652
    8753        $attachments = get_posts( $args );
    8854
     55        foreach ( (array) $attachments as $attachment_id => $attachment_value ) {
     56                echo '<div class="popup" data-popup="popup-' . absint( $attachment_value->ID ) . '">';
     57                echo '<div class="popup-inner">';
    8958
    90   foreach ( (array) $attachments as $attachment_id => $attachment_value ) {
    91         $field = get_post_meta( $attachment_value->ID, 'button_url_buttontitle'.$attachment_value->ID, true );
    92         print_r( $field );
    93   echo '<div class="popup" data-popup="popup-'.$attachment_value->ID.'">';
    94   echo '<div class="popup-inner">';
    95         echo '<p>';
    96         echo  '<a><label for="button_url_buttonurl'.$attachment_value->ID.'">'._e( "Insert Button Url   ", "button_url" ).'   </label></a>';
    97         echo  '<a><input maxlength="160" type="text" name="button_url_buttonurl'.$attachment_value->ID.'" id="button_url_buttonurl'.$attachment_value->ID.'" value="'.button_url_get_meta( "button_url_buttonurl" .$attachment_value->ID ).'"></a>';
    98         echo '  </p>';
     59                echo '<p>';
     60                echo '<a><label for="button_url_buttonurl' . absint( $attachment_value->ID ) . '">' . esc_html__( 'Insert Button Url', 'spartan-gallery' ) . '</label></a>';
     61                echo '<a><input maxlength="160" type="text" name="button_url_buttonurl' . absint( $attachment_value->ID ) . '" id="button_url_buttonurl' . absint( $attachment_value->ID ) . '" value="' . esc_attr( button_url_get_meta( 'button_url_buttonurl' . $attachment_value->ID ) ) . '"></a>';
     62                echo '</p>';
    9963
    100         echo '<p>';
    101         echo  '<a><label for="button_url_buttonurl'.$attachment_value->ID.'">'._e( "Insert Button Title   ", "button_url" ).'   </label></a>';
    102         echo  '<a><input maxlength="160" type="text" name="button_url_buttontitle'.$attachment_value->ID.'" id="button_url_buttontitle'.$attachment_value->ID.'" value="'.button_url_get_meta( "button_url_buttontitle" .$attachment_value->ID ).'"></a>';
    103         echo '  </p>';
     64                echo '<p>';
     65                echo '<a><label for="button_url_buttontitle' . absint( $attachment_value->ID ) . '">' . esc_html__( 'Insert Button Title', 'spartan-gallery' ) . '</label></a>';
     66                echo '<a><input maxlength="160" type="text" name="button_url_buttontitle' . absint( $attachment_value->ID ) . '" id="button_url_buttontitle' . absint( $attachment_value->ID ) . '" value="' . esc_attr( button_url_get_meta( 'button_url_buttontitle' . $attachment_value->ID ) ) . '"></a>';
     67                echo '</p>';
    10468
    105         echo '<p>';
    106         echo  '<a><label for="imgtitle'.$attachment_value->ID.'">'._e( "Insert Image Title   ", "button_url" ).'   </label></a>';
    107         echo  '<a><input maxlength="160" type="text" name="imgtitle'.$attachment_value->ID.'" id="imgtitle'.$attachment_value->ID.'" value="'.button_url_get_meta( "imgtitle" .$attachment_value->ID ).'"></a>';
    108         echo '  </p>';
    109         echo '<p>';
     69                echo '<p>';
     70                echo '<a><label for="imgtitle' . absint( $attachment_value->ID ) . '">' . esc_html__( 'Insert Image Title', 'spartan-gallery' ) . '</label></a>';
     71                echo '<a><input maxlength="160" type="text" name="imgtitle' . absint( $attachment_value->ID ) . '" id="imgtitle' . absint( $attachment_value->ID ) . '" value="' . esc_attr( button_url_get_meta( 'imgtitle' . $attachment_value->ID ) ) . '"></a>';
     72                echo '</p>';
    11073
    111         echo  '<a><label for="imgdescription'.$attachment_value->ID.'">'._e( "Insert Image Description   ", "button_url" ).'   </label></a>';
    112         echo  '<a><input maxlength="160" type="text" name="imgdescription'.$attachment_value->ID.'" id="imgdescription'.$attachment_value->ID.'" value="'.button_url_get_meta( "imgdescription" .$attachment_value->ID ).'"></a>';
    113         echo '  </p>';
    114   echo '<p><a id="close-popup" data-popup-close="popup-'.$attachment_value->ID.'" href="#">Close</a></p>';
    115   echo ' <a id="close-popup" class="popup-close" data-popup-close="popup-'.$attachment_value->ID.'" href="#">x</a>';
    116   echo '</div>';
    117   echo '</div>';
     74                echo '<p>';
     75                echo '<a><label for="imgdescription' . absint( $attachment_value->ID ) . '">' . esc_html__( 'Insert Image Description', 'spartan-gallery' ) . '</label></a>';
     76                echo '<a><input maxlength="160" type="text" name="imgdescription' . absint( $attachment_value->ID ) . '" id="imgdescription' . absint( $attachment_value->ID ) . '" value="' . esc_attr( button_url_get_meta( 'imgdescription' . $attachment_value->ID ) ) . '"></a>';
     77                echo '</p>';
    11878
     79                echo '<p><a id="close-popup" data-popup-close="popup-' . absint( $attachment_value->ID ) . '" href="#">' . esc_html__( 'Close', 'spartan-gallery' ) . '</a></p>';
     80                echo '<a id="close-popup" class="popup-close" data-popup-close="popup-' . absint( $attachment_value->ID ) . '" href="#">x</a>';
     81                echo '</div>';
     82                echo '</div>';
     83        }
    11984}
    12085
    121 }
    122 
    123 
    124 
    125 /**
    126 * Image gallerry button
    127 *
    128 * @since Spartan Gallery 1.0.2
    129 *
    130 * @param array  $urls           URLs to print for resource hints.
    131 * @param string $relation_type  The relation type the URLs are printed.
    132 * @return array $urls           URLs to print for resource hints.
    133 */
    13486function button_url_save( $post_id ) {
    13587        if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return;
    … …  
    13789        if ( ! current_user_can( 'edit_post', $post_id ) ) return;
    13890
    139                                 $args = array(
    140                                         'post_type'   => 'attachment',
    141                                         'numberposts' => -1,
    142                                         //'post_parent' => $page_id,
    143                                         'post_status' => null,
    144                                         'meta_query'  => array(
    145                                                 array(
    146                                                         'key'     => 'spartan_gallery',
    147                                                         'compare' => '=',
    148                                                 )
    149                                         )
     91        $args = array(
     92                'post_type'   => 'attachment',
     93                'numberposts' => -1,
     94                'post_status' => null,
     95                'meta_query'  => array(
     96                        array(
     97                                'key'     => 'spartan_gallery',
     98                                'compare' => '=',
     99                        )
     100                )
     101        );
    150102
    151                                 );
     103        $attachments = get_posts( $args );
    152104
    153                                 $attachments = get_posts( $args );
    154         foreach ( (array) $attachments as $attachments_id => $attachment_value ) {
     105        foreach ( (array) $attachments as $attachments_id => $attachment_value ) {
     106                $id = $attachment_value->ID;
    155107
    156                 if ( sanitize_text_field(  isset($_POST['button_url_buttonurl'.$attachment_value->ID.'']) ) )
    157                         update_post_meta( $post_id, 'button_url_buttonurl'.$attachment_value->ID.'', $_POST['button_url_buttonurl'.$attachment_value->ID.''] );
     108                if ( isset( $_POST[ 'button_url_buttonurl' . $id ] ) ) {
     109                        update_post_meta( $post_id, 'button_url_buttonurl' . $id, sanitize_text_field( wp_unslash( $_POST[ 'button_url_buttonurl' . $id ] ) ) );
     110                }
    158111
    159                 if ( sanitize_text_field( isset($_POST['button_url_buttontitle'.$attachment_value->ID.''] ) ) )
    160                         update_post_meta( $post_id, 'button_url_buttontitle'.$attachment_value->ID.'', $_POST['button_url_buttontitle'.$attachment_value->ID.''] );
     112                if ( isset( $_POST[ 'button_url_buttontitle' . $id ] ) ) {
     113                        update_post_meta( $post_id, 'button_url_buttontitle' . $id, sanitize_text_field( wp_unslash( $_POST[ 'button_url_buttontitle' . $id ] ) ) );
     114                }
    161115
    162                 if ( sanitize_text_field( isset($_POST['imgtitle'.$attachment_value->ID.'']) ) )
    163                         update_post_meta( $post_id, 'imgtitle'.$attachment_value->ID.'', $_POST['imgtitle'.$attachment_value->ID.''] );
     116                if ( isset( $_POST[ 'imgtitle' . $id ] ) ) {
     117                        update_post_meta( $post_id, 'imgtitle' . $id, sanitize_text_field( wp_unslash( $_POST[ 'imgtitle' . $id ] ) ) );
     118                }
    164119
    165                 if ( sanitize_text_field(isset($_POST['imgdescription'.$attachment_value->ID.'']) ) )
    166                         update_post_meta( $post_id, 'imgdescription'.$attachment_value->ID.'', $_POST['imgdescription'.$attachment_value->ID.''] );
    167               }
    168 
     120                if ( isset( $_POST[ 'imgdescription' . $id ] ) ) {
     121                        update_post_meta( $post_id, 'imgdescription' . $id, sanitize_text_field( wp_unslash( $_POST[ 'imgdescription' . $id ] ) ) );
     122                }
     123        }
    169124}
    170125add_action( 'save_post', 'button_url_save' );
  • spartan-gallery/trunk/public/spartan-gallery-styles.php

    r3204032 r3619020  
    1313}
    1414
    15 /**
    16 * Image styles
    17 *
    18 * @since Spartan Gallery 1.0.2
    19 *
    20 * @param array  $urls           URLs to print for resource hints.
    21 * @param string $relation_type  The relation type the URLs are printed.
    22 * @return array $urls           URLs to print for resource hints.
    23 */
    2415Class Spartan_Gallery_Generated_CSS_Output
    2516{
     17    static function output_php_Css( $gallery_id )
     18    {
     19        $image_options_container_settings_on_off   = get_post_meta( $gallery_id, 'container_settings_on_off', true );
     20        $image_options_container_height_width_range = get_post_meta( $gallery_id, 'container_height_width_range', true );
     21        $image_options_container_background_color  = get_post_meta( $gallery_id, 'container_background_color', true );
     22        $image_options_container_border            = get_post_meta( $gallery_id, 'container_border', true );
    2623
     24        $css = '';
    2725
    28       static function output_php_Css( $gallery_id  )
    29       {
    30  
    31                                         $image_options_container_settings_on_off = get_post_meta( $gallery_id , 'container_settings_on_off', true );
    32                                         $image_options_container_height_width_range = get_post_meta( $gallery_id , 'container_height_width_range', true );
    33                                         $image_options_container_background_color = get_post_meta( $gallery_id , 'container_background_color', true );
    34                                         $image_options_container_border = get_post_meta( $gallery_id , 'container_border', true );
     26        if ( $image_options_container_settings_on_off == true ) {
     27            $css .= '
     28                border-top: '    . esc_attr( $image_options_container_border['border-top'] )    . ';
     29                border-right: '  . esc_attr( $image_options_container_border['border-right'] )  . ';
     30                border-bottom: ' . esc_attr( $image_options_container_border['border-bottom'] ) . ';
     31                border-left: '   . esc_attr( $image_options_container_border['border-left'] )   . ';
     32                border-style: '  . esc_attr( $image_options_container_border['border-style'] )  . ';
     33                border-color: '  . esc_attr( $image_options_container_border['border-color'] )  . ';
     34                background-color: ' . esc_attr( $image_options_container_background_color ) . ';
     35                height: '        . esc_attr( $image_options_container_height_width_range['height'] ) . ';
     36                width: '         . esc_attr( $image_options_container_height_width_range['width'] )  . ';
     37            ';
     38        }
    3539
    36                                        
    37                                         $css = '';
    38                                         //$css .= '<style>';
    39                                                 if ( $image_options_container_settings_on_off  == true ) {
    40                                                 $css .= '
    41                                                                
    42                                                                         border-top: '.$image_options_container_border['border-top'].' ; 
    43                                                                         border-right: '.$image_options_container_border['border-right'].';
    44                                                                         border-bottom: '.$image_options_container_border['border-bottom'].';
    45                                                                         border-left: '.$image_options_container_border['border-left'].';
    46                                                                         border-style: '.$image_options_container_border['border-style'].';
    47                                                                         border-color: '.$image_options_container_border['border-color'].';
    48                                                                         background-color: '.$image_options_container_background_color.';
    49                                                                         height: '.$image_options_container_height_width_range['height'].';
    50                                                                         width: '.$image_options_container_height_width_range['width'].';
    51                                                                 ';
    52                                                 }
    53                                                
    54 
    55                                         //$css .= '</style>';
    56 
    57                                         return $css;
    58 
    59                         }
    60 
    61 
     40        return $css;
     41    }
    6242}
  • spartan-gallery/trunk/readme.txt

    r3204032 r3619020  
    22
    33Contributors:       Freelancer Martin
    4 Tags:               gallery, portfolio, simple portfolio gallery, photo gallery, art gallery, photographer gallery,
     4Tags:               gallery, portfolio, photo gallery, gutenberg, responsive
    55Requires at least: 4.6
    6 Tested up to: 6.7
    7 Requires PHP: 8.3
    8 Stable tag:         1.3.0
     6Tested up to: 7.0
     7Requires PHP: 7.4
     8Stable tag:         1.4.0
    99License:            GPLv2 or later
    10 License URI:        [http://www.gnu.org/licenses/gpl-2.0.html](http://www.gnu.org/licenses/gpl-2.0.html)
     10License URI:        http://www.gnu.org/licenses/gpl-2.0.html
    1111
    1212== Description ==
    1313
    14 Spartan Gallery allows you to create gallery very very easily. Spartan Gallery is a responsive and multipurpose portfolio gallery plugin. You can use it for: agency, personal portfolio, architect agency, architecture portfolio, photography studios, creative agency, design studios, painter portfolio, model agency, escort agency, products showcase, artworks, art, artist portfolio, web design works, illustrators, projects, blog, freelance designer etc.
    15 This plugin is truly best for individual who want to deal with numerous of photos. This plugin is also designed with stunning modern style. More over, with plugin option panel. You can change almost everything easily via admin panel. Spartan Gallery is responsive and supports all devices, user-friendly and fine-looking. It is very nice with its clean and professional look.
     14Spartan Gallery is a responsive, multipurpose portfolio gallery plugin for WordPress. It works well for agencies, personal portfolios, architecture and photography studios, product showcases, artist portfolios, and blogs.
    1615
    17 Now added Redux Framework, added gutenberg block to add gallerys on site, fixed some issuses with plugin
     16Six layout styles are included: Freewall Chaotic, Random, Fixed, Pinterest, Hexagon, and 3D Slider. Each gallery has its own options panel to control image size, thumbnail behavior, container styling, and custom CSS, plus a Gutenberg block for adding galleries anywhere in the block editor.
    1817
    1918= Visit Example Site  =
    … …  
    4443If installing the plugin from wordpress.org:
    4544
    46 1 . Upload or Intall the entire /Spartan Gallery directory to the /wp-content/plugins/ directory.
    47 2 . Upload the entire plugin directory to the /wp-content/plugins/ directory.
    48 3 . Activate Spartan Gallery through the 'Plugins' menu in WordPress.
    49 4 . Go to Create New Gallery
    50 5 . Upload Images -> choose layouts options -> select image settings
    51 6 . Copy and Paste shortcode, where would you like see gallery
    52 7 . Profit.
     451. Upload or install the entire /spartan-gallery directory to the /wp-content/plugins/ directory, or install directly through the 'Plugins' screen in WordPress.
     462. Activate Spartan Gallery through the 'Plugins' menu in WordPress.
     473. Go to Spartan Gallery > Add New to create a gallery.
     484. Upload images, choose a layout, and select image settings.
     495. Copy the shortcode (or use the Gutenberg block) wherever you'd like the gallery to appear.
    5350
    5451
    … …  
    7471== Changelog ==
    7572
     73= 1.4.0 =
     74* Removed the Redux Framework dependency; the gallery options panel is now a native WordPress metabox (no third-party plugin required).
     75* Fixed images being stretched/distorted in all six layouts.
     76* Fixed several settings (thumbnail size, adjustable image, container settings) not saving correctly when turned off.
     77* Fixed slider controls not being usable in the options panel.
     78* Removed the "display text under image" caption feature.
     79* Various security hardening and bug fixes.
     80
    7681= 1.3.0 =
    77 * Version 1.0.0 - First Stable Release
    78 * Version 1.2.0 - Upate user interface, new core and class system, new proper class system for plugin
    79 * Version 1.3.0 - Now using redux framework, added gutenbergblock, changed UI, proper testing, made sure everylaout is working, fixed UI
     82* Added Gutenberg block support.
     83* UI improvements and layout fixes.
     84
     85= 1.2.0 =
     86* Updated user interface; new core class system for the plugin.
     87
     88= 1.0.0 =
     89* First stable release.
     90
     91== Upgrade Notice ==
     92
     93= 1.4.0 =
     94Removes the Redux Framework dependency in favor of a built-in options panel — your existing gallery settings carry over automatically. If Redux Framework was installed only for this plugin, it can now be deactivated.
  • spartan-gallery/trunk/spartan-gallery.php

    r3204032 r3619020  
    1515 * @wordpress-plugin
    1616 * Plugin Name:       Spartan Gallery
    17  * Plugin URI:        spartan-gallery.developerforwebsites.com
    18  * Description:       This is a short description of what the plugin does. It's displayed in the WordPress admin area.
    19  * Version:           1.0.0
     17 * Description:       A responsive, multipurpose gallery plugin with six layout styles (Freewall Chaotic, Random, Fixed, Pinterest, Hexagon, and 3D Slider), a Gutenberg block, and per-gallery image/container styling options.
     18 * Version:           1.4.0
    2019 * Author:            Freelancer Martin
    21  * Author URI:        developerforwebsites@gmail.com
     20 * Author URI:        https://freelancermartin.com
    2221 * License:           GPL-2.0+
    2322 * License URI:       http://www.gnu.org/licenses/gpl-2.0.txt
    … …  
    3635 * Rename this for your plugin and update it as you release new versions.
    3736 */
    38 define( 'PLUGIN_NAME_VERSION', '1.2.1' );
     37define( 'PLUGIN_NAME_VERSION', '1.4.0' );
    3938
    4039
    … …  
    8180
    8281
    83 //require_once plugin_dir_path( __FILE__ ) . 'admin/exopite-simple-options/exopite-simple-options-framework-class.php';
    84 
    8582/**
    8683 * The code that runs during plugin deactivation.
Note: See TracChangeset for help on using the changeset viewer.