Esempio n. 1
0
    public static function edit_settings()
    {
        $settings = self::getOptions();
        $themes = self::load_available_themes();
        $themes = array_keys($themes);
        $themes = array_combine($themes, $themes);
        $themes = array_merge(array('' => self::__(' - None / No CSS -')), $themes);
        /**
         * Currency formatting.  Names are pretty clear.
         * 'currency_symbol'                => '$',
         * 'currency_thusands_separator'    => ',',
         * 'currency_decimal_separator'    => '.',
         * 'currency_decimal_precision'    => '2',
         * // Date format.  Uses PHP formats: http://php.net/manual/en/function.date.php
         * 'date_format'                    => 'm/d/Y',
         */
        $dropdown_array = array('manage_options' => self::__('Administrator'), 'edit_others_posts' => self::__('Editor'), 'publish_posts' => self::__('Author'), 'edit_posts' => self::__('Contributor'), 'read' => self::__('Subscriber'));
        $permission_dropdown = self::dropdown_array("permissions_lowest_role", $settings['permissions_lowest_role'], $dropdown_array);
        $dropdown_array = array(1 => self::__("Any items"), 2 => self::__("Only their own items"));
        $permission_user_dropdown = self::dropdown_array("permissions_user_restricted", $settings['permissions_user_restricted'], $dropdown_array);
        $date_format_dropdown = self::dropdown_date_format("date_format", $settings['date_format']);
        $dropdown_array = array('' => self::__('Do not display'), 'g:i' => '3:45', 'h:i' => '03:45', 'g:i a' => '3:45 pm', 'h:i a' => '03:45 pm', 'g:i A' => '3:45 PM', 'h:i A' => '03:45 PM', 'H:i' => '15:45', 'H:i a' => '15:45 pm', 'H:i A' => '15:45 PM');
        $time_format_dropdown = self::dropdown_array("time_format", $settings['time_format'], $dropdown_array);
        $currency_symbol_location_array = array('0' => self::__('Before'), '1' => self::__('After'));
        $currency_decimal_precision_array = array(0 => 0, 1 => 1, 2 => 2, 3 => 3, 4 => 4);
        $permalinks = get_option('permalink_structure');
        $permalink_tip = '';
        if (!$permalinks) {
            $settings['seo_urls'] = 0;
            $permalink_tip = '<p class="description">' . self::__('SEO URLs will not work with your current ') . '<a href="options-permalink.php">' . self::__('Permalink Structure') . '</a></p>';
        }
        $add_ons = self::get_add_ons(TRUE);
        $all_reg_info = self::get_reg_info();
        $reg_tip = array();
        $reg_info = isset($all_reg_info['core']) ? $all_reg_info['core'] : FALSE;
        $reg_tip['core'] = empty($reg_info['expires']) || $reg_info['expires'] < time() ? '<p class="license license_invalid">' . self::__('License key is invalid or expired.') . '</p>' : '<p class="license license_valid">' . sprintf(self::__('License key is valid until %s'), self::format_date($reg_info['expires'])) . '</p>';
        foreach ($add_ons as $key => $add_on) {
            $reg_info = isset($all_reg_info[$add_on->key]) ? $all_reg_info[$add_on->key] : FALSE;
            $reg_tip[$add_on->key] = empty($reg_info['expires']) || $reg_info['expires'] < time() ? '<p class="license license_invalid">' . self::__('License key is invalid or expired.') . '</p>' : '<p class="license license_valid">' . sprintf(self::__('License key is valid until %s'), self::format_date($reg_info['expires'])) . '</p>';
        }
        ?>
		<form method="post" action="<?php 
        echo self::$self_url;
        ?>
" class="inventory-config">
			<table class="form-table">
				<tr>
					<th colspan="2"><h3><?php 
        self::_e('Inventory Manager License Keys');
        ?>
</h3></th>
				</tr>
				<tr>
					<td><?php 
        self::_e('Inventory Manager License Key');
        ?>
</td>
					<td><input type="text" class="large-text" style="max-width: 300px;" name="license_key"
					           value="<?php 
        echo $settings['license_key'];
        ?>
"/>
						<?php 
        echo $reg_tip['core'];
        ?>
</td>
				</tr>
				<?php 
        foreach ($add_ons as $add_on) {
            $value = isset($settings['license_key_' . $add_on->key]) ? $settings['license_key_' . $add_on->key] : '';
            echo '<tr><td>' . sprintf(self::__('%s License Key'), $add_on->item_name) . '</td>';
            echo '<td><input type="text" class="large-text" style="max-width:300px;" name="license_key_' . $add_on->key . '" value="' . $value . '" > ';
            echo $reg_tip[$add_on->key];
            echo '</td></tr>';
        }
        ?>
				<tr>
					<th colspan="2"><h3><?php 
        self::_e('Permission Settings');
        ?>
</h3></th>
				</tr>
				<tr>
					<th><?php 
        self::_e('Minimum Role to Add/Edit Items');
        ?>
</th>
					<td><?php 
        echo $permission_dropdown;
        ?>
</td>
				</tr>
				<tr>
					<th><?php 
        self::_e('Allow Users to Edit');
        ?>
</th>
					<td><?php 
        echo $permission_user_dropdown;
        ?>
</td>
				</tr>
				<tr>
					<th colspan="2"><h3><?php 
        self::_e('General Settings');
        ?>
</h3></th>
				</tr>
				<tr>
					<th><?php 
        self::_e('Use SEO URLs');
        ?>
</th>
					<td><?php 
        echo self::dropdown_yesno("seo_urls", $settings['seo_urls']);
        echo $permalink_tip;
        ?>
</td>
				</tr>

				<tr class="seo_urls">
					<th><?php 
        self::_e('SEO Endpoint');
        ?>
</th>
					<td><input type="text" class="medium-text" name="seo_endpoint"
					           value="<?php 
        echo $settings['seo_endpoint'];
        ?>
"/></td>
				</tr>
				<tr>
					<th><?php 
        self::_e('Theme');
        ?>
</th>
					<td><?php 
        echo self::dropdown_array("theme", $settings['theme'], $themes, 'wpinventory_themes');
        echo '<div class="theme_screenshot"></div>';
        ?>
</td>
				</tr>
				<tr>
					<th><?php 
        self::_e('Use Media Fields');
        ?>
</th>
					<td><?php 
        echo self::dropdown_yesno("use_media", $settings['use_media']);
        ?>
						<p class="description"><?php 
        self::_e('Setting this to no still allows images, just not additional media');
        ?>
					</td>
				</tr>
				<tr>
					<th><?php 
        self::_e('Items Per Page');
        ?>
</th>
					<td><input type="text" class="small-text" name="page_size"
					           value="<?php 
        echo $settings['page_size'];
        ?>
"></td>
				</tr>
				<tr>
					<th colspan="2"><h3><?php 
        self::_e('Date Format Settings');
        ?>
</h3></th>
				</tr>
				<tr>
					<th><?php 
        self::_e('Date Format');
        ?>
</th>
					<td><?php 
        echo $date_format_dropdown;
        ?>
</td>
				</tr>
				<tr>
					<th><?php 
        self::_e('Time Format');
        ?>
</th>
					<td><?php 
        echo $time_format_dropdown;
        ?>
</td>
				</tr>
				<tr>
					<th colspan="2"><h3><?php 
        self::_e('Currency Format Settings');
        ?>
</h3></th>
				</tr>
				<tr>
					<th><?php 
        self::_e('Currency Symbol');
        ?>
</th>
					<td><input type="text" name="currency_symbol" class="small-text"
					           value="<?php 
        echo $settings['currency_symbol'];
        ?>
"/></td>
				</tr>
				<tr>
					<th><?php 
        self::_e('Currency Symbol Location');
        ?>
</th>
					<td><?php 
        echo self::dropdown_array('currency_symbol_location', $settings['currency_symbol_location'], $currency_symbol_location_array);
        ?>
</td>
				</tr>
				<tr>
					<th><?php 
        self::_e('Currency Thousands Separator');
        ?>
</th>
					<td><input type="text" name="currency_thousands_separator" class="small-text"
					           value="<?php 
        echo $settings['currency_thousands_separator'];
        ?>
"/></td>
				</tr>
				<tr>
					<th><?php 
        self::_e('Currency Decimal Separator');
        ?>
</th>
					<td><input type="text" name="currency_decimal_separator" class="small-text"
					           value="<?php 
        echo $settings['currency_decimal_separator'];
        ?>
"/></td>
				</tr>
				<tr>
					<th><?php 
        self::_e('Currency Precision (decimal places)');
        ?>
</th>
					<td><?php 
        echo self::dropdown_array('currency_decimal_precision', $settings['currency_decimal_precision'], $currency_decimal_precision_array);
        ?>
</td>
				</tr>
				<tr>
					<td><?php 
        self::_e('Currency Example (with settings):');
        ?>
</td>
					<td><?php 
        echo self::format_currency(45250.25555);
        ?>
				</tr>
				<tr>
					<th colspan="2"><h3><?php 
        self::_e('Reserve Settings');
        ?>
</h3></th>
				</tr>
				<tr>
					<th><?php 
        self::_e('Allow Visitors to Reserve Items');
        ?>
</th>
					<td><?php 
        echo self::dropdown_yesno("reserve_allow", $settings['reserve_allow']);
        ?>
</td>
				</tr>
				<tr class="reserve">
					<th><?php 
        self::_e('Ask for Qty When Reserving');
        ?>
</th>
					<td><?php 
        echo self::dropdown_yesno("reserve_quantity", $settings['reserve_quantity']);
        ?>
</td>
				</tr>
				<tr class="reserve">
					<th><?php 
        self::_e('Decrease Qty in System on Reserve');
        ?>
</th>
					<td><?php 
        echo self::dropdown_yesno("reserve_decrement", $settings['reserve_decrement']);
        ?>
</td>
				</tr>
				<tr class="reserve">
					<th><?php 
        self::_e('Send-to Email When Reserve');
        ?>
</th>
					<td><input type="text" class="widefat" name="reserve_email"
					           value="<?php 
        echo $settings['reserve_email'];
        ?>
">
					<p class="description"><?php 
        self::_e('If left blank, the E-Mail Address from Settings -> General will be used.');
        ?>
</p></td>
				</tr>
				<tr class="reserve">
					<th><?php 
        self::_e('Send Reserve Confirmation');
        ?>
</th>
					<td><?php 
        echo self::dropdown_yesno("reserve_confirmation", $settings['reserve_confirmation']);
        ?>
					<p class="description">Should a confirmation e-mail be sent to the submitter when a reserve form is submitted?</p></td>
				</tr>
				<tr class="reserve">
					<th><?php 
        self::_e('Require Name');
        ?>
</th>
					<td><?php 
        echo self::dropdown_required("reserve_require_name", $settings['reserve_require_name']);
        ?>
</td>
				</tr>
				<tr class="reserve">
					<th><?php 
        self::_e('Require Address');
        ?>
</th>
					<td><?php 
        echo self::dropdown_required("reserve_require_address", $settings['reserve_require_address']);
        ?>
</td>
				</tr>
				<tr class="reserve">
					<th><?php 
        self::_e('Require City');
        ?>
</th>
					<td><?php 
        echo self::dropdown_required("reserve_require_city", $settings['reserve_require_city']);
        ?>
</td>
				</tr>
				<tr class="reserve">
					<th><?php 
        self::_e('Require State');
        ?>
</th>
					<td><?php 
        echo self::dropdown_required("reserve_require_state", $settings['reserve_require_state']);
        ?>
</td>
				</tr>
				<tr class="reserve">
					<th><?php 
        self::_e('Require Zip');
        ?>
</th>
					<td><?php 
        echo self::dropdown_required("reserve_require_zip", $settings['reserve_require_zip']);
        ?>
</td>
				</tr>
				<tr class="reserve">
					<th><?php 
        self::_e('Require Phone');
        ?>
</th>
					<td><?php 
        echo self::dropdown_required("reserve_require_phone", $settings['reserve_require_phone']);
        ?>
</td>
				</tr>
				<tr class="reserve">
					<th><?php 
        self::_e('Require Email');
        ?>
</th>
					<td><?php 
        echo self::dropdown_required("reserve_require_email", $settings['reserve_require_email']);
        ?>
</td>
				</tr>
				<tr class="reserve">
					<th><?php 
        self::_e('Require Message');
        ?>
</th>
					<td><?php 
        echo self::dropdown_required("reserve_require_message", $settings['reserve_require_message']);
        ?>
</td>
				</tr>
			</table>
			<?php 
        do_action('wpim_edit_settings');
        ?>
			<table class="form-table">
				<?php 
        // TODO: Move this to a tools subsection
        ?>
				<tr>
					<th colspan="2"><h3><?php 
        self::_e('Image Tools');
        ?>
</h3></th>
				</tr>
				<tr>
					<th><?php 
        self::_e('Placeholder Image');
        ?>
</th>
					<td>
						<div data-type="image" class="media-container">
							<?php 
        $placeholder = wpinventory_get_placeholder_image('all');
        self::item_image_field(0, $placeholder, 'placeholder_image');
        ?>
						</div>
					</td>
				</tr>
				<tr>
					<th><?php 
        self::_e('Rebuild Image Thumbnails');
        ?>
</th>
					<td><input type="checkbox" name="rebuild_thumbnails"/></td>
				</tr>
			</table>
			<input type="hidden" name="action" value="save"/>

			<p class="submit">
				<a href="<?php 
        echo self::$self_url;
        ?>
" class="button"><?php 
        self::_e('Cancel');
        ?>
</a>
				<input type="submit" class="button-primary" name="save" value="<?php 
        self::_e('Save Settings');
        ?>
"/>
				<a class="button"
				   href="<?php 
        echo self::$self_url;
        ?>
&action=default"><?php 
        self::_e('Reset to Defaults');
        ?>
</a>
			</p>
		</form>
		<script>
			jQuery(function ($) {
				$('.inventory-config').on('change', 'select[name="seo_urls"]', function () {
					if ($(this).val() == "1") {
						$('tr.seo_urls').fadeIn();
					} else {
						$('tr.seo_urls').fadeOut();
					}
				});

				$('.inventory-config').on('change', 'select[name="reserve_allow"]', function () {
					if ($(this).val() == "1") {
						$('tr.reserve').fadeIn();
					} else {
						$('tr.reserve').fadeOut();
					}
				});

				$('select[name="seo_urls"], select[name="reserve_allow"]').trigger('change');
				<?php 
        do_action('wpim_edit_settings_script');
        ?>
			});
		</script>
	<?php 
    }
Esempio n. 2
0
function wpinventory_get_the_featured_image($size = 'thumbnail')
{
    $images = wpinventory_get_the_images($size, 1);
    if (is_array($images) && !empty($images[0])) {
        return $images[0];
    }
    // Should never get here.  wpinventory_get_the_images should get / return placeholder if appropriate
    $placeholder = wpinventory_get_placeholder_image($size);
    return $placeholder;
}