예제 #1
0
        /**
         * Output the frontend styles settings.
         *
         * @access public
         * @return void
         */
        public function frontend_styles_setting()
        {
            ?>
<tr valign="top" class="woocommerce_frontend_css_colors">
			<th scope="row" class="titledesc">
				<?php 
            _e('Frontend Styles', 'qsot');
            ?>
			</th>
			<td class="forminp"><?php 
            $base_file = QSOT::plugin_dir() . 'assets/css/frontend/event-base.less';
            $css_file = QSOT::plugin_dir() . 'assets/css/frontend/event.css';
            if (is_writable($base_file) && is_writable(dirname($css_file))) {
                $options = qsot_options::instance();
                // Get settings
                $colors = array_map('esc_attr', QSOT::current_colors());
                $defaults = array_map('esc_attr', QSOT::default_colors());
                // Show inputs
                echo '<div class="color-selection">';
                echo '<h4>' . __('Ticket Selection UI', 'opentickets-community-edition') . '</h4>';
                $this->color_picker(__('Form BG', 'opentickets-community-edition'), 'qsot_frontend_css_form_bg', $colors['form_bg'], $defaults['form_bg'], __('Background color of the "reserve some tickets" form on the event page.', 'opentickets-community-edition'));
                $this->color_picker(__('Form Border', 'opentickets-community-edition'), 'qsot_frontend_css_form_border', $colors['form_border'], $defaults['form_border'], __('Border color around the "reserve some tickets" form.', 'opentickets-community-edition'));
                $this->color_picker(__('Action BG', 'opentickets-community-edition'), 'qsot_frontend_css_form_action_bg', $colors['form_action_bg'], $defaults['form_action_bg'], __('Background of the "action" section, below the "reserve some tickets" form, where the proceed to cart button appears.', 'opentickets-community-edition'));
                $this->color_picker(__('Helper', 'opentickets-community-edition'), 'qsot_frontend_css_form_helper', $colors['form_helper'], $defaults['form_helper'], __('Text color of the "helper text" on the "reserve some tickets" form.', 'opentickets-community-edition'));
                echo '<div class="clear"></div>';
                $this->color_picker(__('Bad BG', 'opentickets-community-edition'), 'qsot_frontend_css_bad_msg_bg', $colors['bad_msg_bg'], $defaults['bad_msg_bg'], __('Background color of the error message block on the "reserve some tickets" form.', 'opentickets-community-edition'));
                $this->color_picker(__('Bad Border', 'opentickets-community-edition'), 'qsot_frontend_css_bad_msg_border', $colors['bad_msg_border'], $defaults['bad_msg_border'], __('Border color around the error message block on the "reserve some tickets" form.', 'opentickets-community-edition'));
                $this->color_picker(__('Bad Text', 'opentickets-community-edition'), 'qsot_frontend_css_bad_msg_text', $colors['bad_msg_text'], $defaults['bad_msg_text'], __('Text color of the error message block on the "reserve some tickets" form.', 'opentickets-community-edition'));
                echo '<div class="clear"></div>';
                $this->color_picker(__('Good BG', 'opentickets-community-edition'), 'qsot_frontend_css_good_msg_bg', $colors['good_msg_bg'], $defaults['good_msg_bg'], __('Background color of the success message block on the "reserve some tickets" form.', 'opentickets-community-edition'));
                $this->color_picker(__('Good Border', 'opentickets-community-edition'), 'qsot_frontend_css_good_msg_border', $colors['good_msg_border'], $defaults['good_msg_border'], __('Border color around the success message block on the "reserve some tickets" form.', 'opentickets-community-edition'));
                $this->color_picker(__('Good Text', 'opentickets-community-edition'), 'qsot_frontend_css_good_msg_text', $colors['good_msg_text'], $defaults['good_msg_text'], __('Text color of the success message block on the "reserve some tickets" form.', 'opentickets-community-edition'));
                echo '<div class="clear"></div>';
                $this->color_picker(__('Remove BG', 'opentickets-community-edition'), 'qsot_frontend_css_remove_bg', $colors['remove_bg'], $defaults['remove_bg'], __('Background color of the remove reservation button on the "reserve some tickets" form.', 'opentickets-community-edition'));
                $this->color_picker(__('Remove Border', 'opentickets-community-edition'), 'qsot_frontend_css_remove_border', $colors['remove_border'], $defaults['remove_border'], __('Border color around the remove reservation button on the "reserve some tickets" form.', 'opentickets-community-edition'));
                $this->color_picker(__('Remove Text', 'opentickets-community-edition'), 'qsot_frontend_css_remove_text', $colors['remove_text'], $defaults['remove_text'], __('Text color of the remove reservation button on the "reserve some tickets" form.', 'opentickets-community-edition'));
                echo '<div class="clear"></div>';
                echo '</div>';
                // calendar
                echo '<div class="color-selection">';
                echo '<h4>' . __('Calendar', 'openticket-community-edition') . '</h4>';
                $this->color_picker(__('Calendar Item BG', 'opentickets-community-edition'), 'qsot_frontend_css_calendar_item_bg', $colors['calendar_item_bg'], $defaults['calendar_item_bg'], __('The background color of the active items shown on the calendar.', 'opentickets-community-edition'));
                $this->color_picker(__('Calendar Item Border', 'opentickets-community-edition'), 'qsot_frontend_css_calendar_item_border', $colors['calendar_item_border'], $defaults['calendar_item_border'], __('The border color of the active items shown on the calendar.', 'opentickets-community-edition'));
                $this->color_picker(__('Calendar Item Text', 'opentickets-community-edition'), 'qsot_frontend_css_calendar_item_text', $colors['calendar_item_text'], $defaults['calendar_item_text'], __('The text color of the active items shown on the calendar.', 'opentickets-community-edition'));
                $this->color_picker(__('Calendar Item Hover', 'opentickets-community-edition'), 'qsot_frontend_css_calendar_item_text_hover', $colors['calendar_item_text_hover'], $defaults['calendar_item_text_hover'], __('The HOVER text color of the active items shown on the calendar.', 'opentickets-community-edition'));
                echo '<div class="clear"></dv>';
                $this->color_picker(__('Past Item BG', 'opentickets-community-edition'), 'qsot_frontend_css_past_calendar_item_bg', $colors['past_calendar_item_bg'], $defaults['past_calendar_item_bg'], __('The background color of the items shown on the calendar, that have already passed.', 'opentickets-community-edition'));
                $this->color_picker(__('Past Item Border', 'opentickets-community-edition'), 'qsot_frontend_css_past_calendar_item_border', $colors['past_calendar_item_border'], $defaults['past_calendar_item_border'], __('The border color of the active items shown on the calendari, that have already passed.', 'opentickets-community-edition'));
                $this->color_picker(__('Past Item Text', 'opentickets-community-edition'), 'qsot_frontend_css_past_calendar_item_text', $colors['past_calendar_item_text'], $defaults['past_calendar_item_text'], __('The text color of the active items shown on the calendar, that have already passed.', 'opentickets-community-edition'));
                $this->color_picker(__('Past Item Hover', 'opentickets-community-edition'), 'qsot_frontend_css_past_calendar_item_text_hover', $colors['past_calendar_item_text_hover'], $defaults['past_calendar_item_text_hover'], __('The HOVER text color of the active items shown on the calendar, that have already passed.', 'opentickets-community-edition'));
                echo '</div>';
                echo '<div class="clear"></div>';
                $u = uniqid('reset-colors-');
                echo '<a href="#" rel="' . $u . '">reset all colors</a>';
                ?>
						<script>
							( function( $ ) {
								$( '[rel="<?php 
                echo $u;
                ?>
"]' ).on( 'click', function( e ) {
									e.preventDefault();
									var td = $( this ).closest( 'td' );
									$( '.colorpick', td ).each( function() {
										var def = $( this ).data( 'default' );
										if ( def ) $( this ).val( def ).trigger( 'change' );
									} );
								} );
							} )( jQuery );
						</script>
					<?php 
            } else {
                echo '<span class="description error-msg">' . sprintf(__('To edit colours %s and %s need to be writable. See <a href="%s">the Codex</a> for more information.', 'opentickets-community-edition'), '<code>opentickets-community-edition/assets/css/frontend/event-base.less</code>', '<code>event.css</code>', 'http://codex.wordpress.org/Changing_File_Permissions') . '</span>';
            }
            ?>
</td>
		</tr><?php 
        }
예제 #2
0
        public static function on_activate()
        {
            // determine the cache dir name
            $u = wp_upload_dir();
            $base_dir_name = 'qsot-dompdf-fonts-' . substr(sha1(site_url()), 21, 5);
            $final_path = $u['basedir'] . DIRECTORY_SEPARATOR . $base_dir_name . DIRECTORY_SEPARATOR;
            try {
                $font_path = QSOT_cache_helper::create_find_path($final_path, 'fonts');
                if (!is_writable($font_path)) {
                    throw new Exception(sprintf(__('The %s path is not writable. Please update the permissions to allow write access.', 'opentickets-community-edition'), 'fonts'));
                }
            } catch (Exception $e) {
                // just fail. we can go without the custom config
                return;
            }
            // make sure that the libs dir is also writable
            $libs_dir = QSOT::plugin_dir() . 'libs/';
            if (!@file_exists($libs_dir) || !is_dir($libs_dir) || !is_writable($libs_dir)) {
                return;
            }
            // find all the fonts that come with the lib we packaged with the plugin, and move them to the new fonts dir, if they are not already there
            $remove_files = $updated_files = array();
            $core_fonts_dir = $libs_dir . 'dompdf/lib/fonts/';
            // open the core included fonts dir
            if (@file_exists($core_fonts_dir) && is_writable($core_fonts_dir) && ($dir = opendir($core_fonts_dir))) {
                // find all the files in the dir
                while ($file_basename = readdir($dir)) {
                    $filename = $core_fonts_dir . $file_basename;
                    $new_filename = $font_path . $file_basename;
                    // if the current file is a dir or link, skip it
                    if (is_dir($filename) || is_link($filename)) {
                        continue;
                    }
                    // overwrite any existing copy of the file, with the new version from the updated plugin
                    if (copy($filename, $new_filename)) {
                        $remove_files[] = $filename;
                        $updated_files[] = basename($filename);
                    }
                }
                file_put_contents($font_path . 'updated', 'updated on ' . date('Y-m-d H:i:s') . ":\n" . implode("\n", $remove_files));
                // attempt to create the new custom config file
                if ($config_file = fopen($libs_dir . 'wp.dompdf.config.php', 'w+')) {
                    // create variable names to use in the heredoc
                    $variable_names = array('$_SERVER["SCRIPT_FILENAME"]');
                    // generate the contents of the config file
                    $contents = <<<CONTENTS
<?php ( __FILE__ == {$variable_names[0]} ) ? die( header( 'Location: /' ) ) : null;
if ( ! defined( 'DOMPDF_FONT_DIR' ) )
\tdefine( 'DOMPDF_FONT_DIR', '{$font_path}' );
if ( ! defined( 'DOMPDF_FONT_CACHE' ) )
\tdefine( 'DOMPDF_FONT_CACHE', '{$font_path}' );
CONTENTS;
                    // write the config file, and close it
                    fwrite($config_file, $contents, strlen($contents));
                    fclose($config_file);
                    // remove any files that are marked to be removed, now that we have successfully written them to the new location, and pointed DOMPDF at them
                    /* skip this for now */
                    /*
                    if ( is_array( $remove_files ) && count( $remove_files ) )
                    	foreach ( $remove_files as $remove_file )
                    		if ( is_writable( $remove_file ) && ! is_dir( $remove_file ) && ! is_link( $remove_file ) )
                    			@unlink( $remove_file );
                    */
                }
            }
        }
예제 #3
0
 protected static function lg()
 {
     if (!self::$debug) {
         return;
     }
     if (!is_resource(self::$log_file)) {
         self::$log_file = fopen(QSOT::plugin_dir() . uniqid('zoner') . '.log', 'a');
     }
     if (is_resource(self::$log_file)) {
         foreach (func_get_args() as $arg) {
             if (is_scalar($arg)) {
                 if ($arg == '*__f__*') {
                     $bt = self::bt(true);
                     $out = 'BACKTRACE: ' . implode("\n", $bt);
                 } else {
                     $out = 'MSG: ' . $arg;
                 }
             } else {
                 $out = 'DUMP: ' . var_export($arg, true);
             }
             $out .= "\n";
             fwrite(self::$log_file, $out, strlen($out));
         }
     }
 }
예제 #4
0
 public static function compile_frontend_styles()
 {
     $colors = self::current_colors();
     $pdir = QSOT::plugin_dir();
     $base_file = $pdir . 'assets/css/frontend/event-base.less';
     $files = array(array($pdir . 'assets/css/frontend/event.less', $pdir . 'assets/css/frontend/event.css'), array($pdir . 'assets/css/features/calendar/calendar.less', $pdir . 'assets/css/features/calendar/calendar.css'));
     // Write less file
     if (is_writable($base_file)) {
         try {
             // first check if lessc is available
             $file = self::$plugin_dir . 'libs/css/lessc.php';
             if (self::_check_one_lib($file, 'LESSC')) {
                 include $file;
             }
             // then check if cssmin is available
             $file = self::$plugin_dir . 'libs/css/cssmin.php';
             if (self::_check_one_lib($file, 'CSSMIN')) {
                 include $file;
             }
         } catch (Exception $e) {
             // upon failure to find a library, just fail, with no message, until we can figure out a good way to transport the message
             return;
         }
         try {
             // create the base file
             $css = array();
             foreach ($colors as $tag => $color) {
                 $css[] = '@' . $tag . ':' . $color . ';';
             }
             file_put_contents($base_file, implode("\n", $css));
             foreach ($files as $file_group) {
                 list($less_file, $css_file) = $file_group;
                 if (is_writable(dirname($css_file))) {
                     try {
                         // create the core css file
                         $less = new lessc();
                         $compiled_css = $less->compileFile($less_file);
                         $compiled_css = CssMin::minify($compiled_css);
                         if ($compiled_css) {
                             file_put_contents($css_file, $compiled_css);
                         }
                     } catch (Exception $ex) {
                         wp_die(sprintf(__('Could not compile stylesheet %s. [%s]', 'opentickets-community-edition'), $less_file, $ex->getMessage()));
                     }
                 } else {
                     wp_die(sprintf(__('Could not write to stylesheet file %s.', 'opentickets-community-edition'), $css_file));
                 }
             }
         } catch (Exception $ex) {
             wp_die(sprintf(__('Could not write colors to file %s. [%s]', 'opentickets-community-edition'), $base_file, $ex->getMessage()));
         }
     }
 }