Example #1
0
/**
 * {@internal Missing Short Description}}
 *
 * @since 0.0.1
 *
 * @param string $found_action
 */
function find_posts_div($found_action = '')
{
    ?>
	<div id="find-posts" class="find-box" style="display: none;">
		<div id="find-posts-head" class="find-box-head">
			<?php 
    _e('Find Posts or Pages');
    ?>
			<div id="find-posts-close"></div>
		</div>
		<div class="find-box-inside">
			<div class="find-box-search">
				<?php 
    if ($found_action) {
        ?>
					<input type="hidden" name="found_action" value="<?php 
        echo esc_attr($found_action);
        ?>
" />
				<?php 
    }
    ?>
				<input type="hidden" name="affected" id="affected" value="" />
				<?php 
    hq_nonce_field('find-posts', '_ajax_nonce', false);
    ?>
				<label class="screen-reader-text" for="find-posts-input"><?php 
    _e('Search');
    ?>
</label>
				<input type="text" id="find-posts-input" name="ps" value="" />
				<span class="spinner"></span>
				<input type="button" id="find-posts-search" value="<?php 
    esc_attr_e('Search');
    ?>
" class="button" />
				<div class="clear"></div>
			</div>
			<div id="find-posts-response"></div>
		</div>
		<div class="find-box-buttons">
			<?php 
    submit_button(__('Select'), 'button-primary alignright', 'find-posts-submit', false);
    ?>
			<div class="clear"></div>
		</div>
	</div>
<?php 
}
Example #2
0
if (has_action('welcome_panel') && current_user_can('edit_theme_options')) {
    $classes = 'welcome-panel';
    $option = get_user_meta(get_current_user_id(), 'show_welcome_panel', true);
    // 0 = hide, 1 = toggled to show or single site creator, 2 = multisite site owner
    $hide = 0 == $option || 2 == $option && hq_get_current_user()->user_email != get_option('admin_email');
    if ($hide) {
        $classes .= ' hidden';
    }
    ?>

	<div id="welcome-panel" class="<?php 
    echo esc_attr($classes);
    ?>
">
		<?php 
    hq_nonce_field('welcome-panel-nonce', 'welcomepanelnonce', false);
    ?>
		<a class="welcome-panel-close" href="<?php 
    echo esc_url(admin_url('?welcome=0'));
    ?>
"><?php 
    _e('Dismiss');
    ?>
</a>
		<?php 
    /**
     * Add content to the welcome panel on the admin dashboard.
     *
     * To remove the default welcome panel, use {@see remove_action()}:
     *
     *     remove_action( 'welcome_panel', 'hq_welcome_panel' );
Example #3
0
    /**
     * Display the custom background page.
     *
     * @since 0.0.1
     */
    public function admin_page()
    {
        ?>
<div class="wrap" id="custom-background">
<h1><?php 
        _e('Custom Background');
        ?>
</h1>

<?php 
        if (current_user_can('customize')) {
            ?>
<div class="notice notice-info hide-if-no-customize">
	<p>
		<?php 
            printf(__('You can now manage and live-preview Custom Backgrounds in the <a href="%1$s">Customizer</a>.'), admin_url('customize.php?autofocus[control]=background_image'));
            ?>
	</p>
</div>
<?php 
        }
        ?>

<?php 
        if (!empty($this->updated)) {
            ?>
<div id="message" class="updated">
<p><?php 
            printf(__('Background updated. <a href="%s">Visit your site</a> to see how it looks.'), home_url('/'));
            ?>
</p>
</div>
<?php 
        }
        ?>

<h3><?php 
        _e('Background Image');
        ?>
</h3>

<table class="form-table">
<tbody>
<tr>
<th scope="row"><?php 
        _e('Preview');
        ?>
</th>
<td>
	<?php 
        if ($this->admin_image_div_callback) {
            call_user_func($this->admin_image_div_callback);
        } else {
            $background_styles = '';
            if ($bgcolor = get_background_color()) {
                $background_styles .= 'background-color: #' . $bgcolor . ';';
            }
            $background_image_thumb = get_background_image();
            if ($background_image_thumb) {
                $background_image_thumb = esc_url(set_url_scheme(get_theme_mod('background_image_thumb', str_replace('%', '%%', $background_image_thumb))));
                // Background-image URL must be single quote, see below.
                $background_styles .= ' background-image: url(\'' . $background_image_thumb . '\');' . ' background-repeat: ' . get_theme_mod('background_repeat', get_theme_support('custom-background', 'default-repeat')) . ';' . ' background-position: top ' . get_theme_mod('background_position_x', get_theme_support('custom-background', 'default-position-x'));
            }
            ?>
	<div id="custom-background-image" style="<?php 
            echo $background_styles;
            ?>
"><?php 
            // must be double quote, see above
            ?>
		<?php 
            if ($background_image_thumb) {
                ?>
		<img class="custom-background-image" src="<?php 
                echo $background_image_thumb;
                ?>
" style="visibility:hidden;" alt="" /><br />
		<img class="custom-background-image" src="<?php 
                echo $background_image_thumb;
                ?>
" style="visibility:hidden;" alt="" />
		<?php 
            }
            ?>
	</div>
	<?php 
        }
        ?>
</td>
</tr>

<?php 
        if (get_background_image()) {
            ?>
<tr>
<th scope="row"><?php 
            _e('Remove Image');
            ?>
</th>
<td>
<form method="post">
<?php 
            hq_nonce_field('custom-background-remove', '_hqnonce-custom-background-remove');
            submit_button(__('Remove Background Image'), 'button', 'remove-background', false);
            ?>
<br/>
<?php 
            _e('This will remove the background image. You will not be able to restore any customizations.');
            ?>
</form>
</td>
</tr>
<?php 
        }
        ?>

<?php 
        $default_image = get_theme_support('custom-background', 'default-image');
        if ($default_image && get_background_image() != $default_image) {
            ?>
<tr>
<th scope="row"><?php 
            _e('Restore Original Image');
            ?>
</th>
<td>
<form method="post">
<?php 
            hq_nonce_field('custom-background-reset', '_hqnonce-custom-background-reset');
            submit_button(__('Restore Original Image'), 'button', 'reset-background', false);
            ?>
<br/>
<?php 
            _e('This will restore the original background image. You will not be able to restore any customizations.');
            ?>
</form>
</td>
</tr>
<?php 
        }
        ?>

<?php 
        if (current_user_can('upload_files')) {
            ?>
<tr>
<th scope="row"><?php 
            _e('Select Image');
            ?>
</th>
<td><form enctype="multipart/form-data" id="upload-form" class="hq-upload-form" method="post">
	<p>
		<label for="upload"><?php 
            _e('Choose an image from your computer:');
            ?>
</label><br />
		<input type="file" id="upload" name="import" />
		<input type="hidden" name="action" value="save" />
		<?php 
            hq_nonce_field('custom-background-upload', '_hqnonce-custom-background-upload');
            ?>
		<?php 
            submit_button(__('Upload'), 'button', 'submit', false);
            ?>
	</p>
	<p>
		<label for="choose-from-library-link"><?php 
            _e('Or choose an image from your media library:');
            ?>
</label><br />
		<button id="choose-from-library-link" class="button"
			data-choose="<?php 
            esc_attr_e('Choose a Background Image');
            ?>
"
			data-update="<?php 
            esc_attr_e('Set as background');
            ?>
"><?php 
            _e('Choose Image');
            ?>
</button>
	</p>
	</form>
</td>
</tr>
<?php 
        }
        ?>
</tbody>
</table>

<h3><?php 
        _e('Display Options');
        ?>
</h3>
<form method="post">
<table class="form-table">
<tbody>
<?php 
        if (get_background_image()) {
            ?>
<tr>
<th scope="row"><?php 
            _e('Position');
            ?>
</th>
<td><fieldset><legend class="screen-reader-text"><span><?php 
            _e('Background Position');
            ?>
</span></legend>
<label>
<input name="background-position-x" type="radio" value="left"<?php 
            checked('left', get_theme_mod('background_position_x', get_theme_support('custom-background', 'default-position-x')));
            ?>
 />
<?php 
            _e('Left');
            ?>
</label>
<label>
<input name="background-position-x" type="radio" value="center"<?php 
            checked('center', get_theme_mod('background_position_x', get_theme_support('custom-background', 'default-position-x')));
            ?>
 />
<?php 
            _e('Center');
            ?>
</label>
<label>
<input name="background-position-x" type="radio" value="right"<?php 
            checked('right', get_theme_mod('background_position_x', get_theme_support('custom-background', 'default-position-x')));
            ?>
 />
<?php 
            _e('Right');
            ?>
</label>
</fieldset></td>
</tr>

<tr>
<th scope="row"><?php 
            _e('Repeat');
            ?>
</th>
<td><fieldset><legend class="screen-reader-text"><span><?php 
            _e('Background Repeat');
            ?>
</span></legend>
<label><input type="radio" name="background-repeat" value="no-repeat"<?php 
            checked('no-repeat', get_theme_mod('background_repeat', get_theme_support('custom-background', 'default-repeat')));
            ?>
 /> <?php 
            _e('No Repeat');
            ?>
</label>
	<label><input type="radio" name="background-repeat" value="repeat"<?php 
            checked('repeat', get_theme_mod('background_repeat', get_theme_support('custom-background', 'default-repeat')));
            ?>
 /> <?php 
            _e('Tile');
            ?>
</label>
	<label><input type="radio" name="background-repeat" value="repeat-x"<?php 
            checked('repeat-x', get_theme_mod('background_repeat', get_theme_support('custom-background', 'default-repeat')));
            ?>
 /> <?php 
            _e('Tile Horizontally');
            ?>
</label>
	<label><input type="radio" name="background-repeat" value="repeat-y"<?php 
            checked('repeat-y', get_theme_mod('background_repeat', get_theme_support('custom-background', 'default-repeat')));
            ?>
 /> <?php 
            _e('Tile Vertically');
            ?>
</label>
</fieldset></td>
</tr>

<tr>
<th scope="row"><?php 
            _ex('Attachment', 'Background Attachment');
            ?>
</th>
<td><fieldset><legend class="screen-reader-text"><span><?php 
            _e('Background Attachment');
            ?>
</span></legend>
<label>
<input name="background-attachment" type="radio" value="scroll" <?php 
            checked('scroll', get_theme_mod('background_attachment', get_theme_support('custom-background', 'default-attachment')));
            ?>
 />
<?php 
            _e('Scroll');
            ?>
</label>
<label>
<input name="background-attachment" type="radio" value="fixed" <?php 
            checked('fixed', get_theme_mod('background_attachment', get_theme_support('custom-background', 'default-attachment')));
            ?>
 />
<?php 
            _e('Fixed');
            ?>
</label>
</fieldset></td>
</tr>
<?php 
        }
        // get_background_image()
        ?>
<tr>
<th scope="row"><?php 
        _e('Background Color');
        ?>
</th>
<td><fieldset><legend class="screen-reader-text"><span><?php 
        _e('Background Color');
        ?>
</span></legend>
<?php 
        $default_color = '';
        if (current_theme_supports('custom-background', 'default-color')) {
            $default_color = ' data-default-color="#' . esc_attr(get_theme_support('custom-background', 'default-color')) . '"';
        }
        ?>
<input type="text" name="background-color" id="background-color" value="#<?php 
        echo esc_attr(get_background_color());
        ?>
"<?php 
        echo $default_color;
        ?>
 />
</fieldset></td>
</tr>
</tbody>
</table>

<?php 
        hq_nonce_field('custom-background');
        submit_button(null, 'primary', 'save-background-options');
        ?>
</form>

</div>
<?php 
    }
Example #4
0
/**
 * Display the default admin color scheme picker (Used in user-edit.php)
 *
 * @since 0.0.1
 *
 * @global array $_hq_admin_css_colors
 */
function admin_color_scheme_picker($user_id)
{
    global $_hq_admin_css_colors;
    ksort($_hq_admin_css_colors);
    if (isset($_hq_admin_css_colors['fresh'])) {
        // Set Default ('fresh') and Light should go first.
        $_hq_admin_css_colors = array_filter(array_merge(array('fresh' => '', 'light' => ''), $_hq_admin_css_colors));
    }
    $current_color = get_user_option('admin_color', $user_id);
    if (empty($current_color) || !isset($_hq_admin_css_colors[$current_color])) {
        $current_color = 'fresh';
    }
    ?>
	<fieldset id="color-picker" class="scheme-list">
		<legend class="screen-reader-text"><span><?php 
    _e('Admin Color Scheme');
    ?>
</span></legend>
		<?php 
    hq_nonce_field('save-color-scheme', 'color-nonce', false);
    foreach ($_hq_admin_css_colors as $color => $color_info) {
        ?>
			<div class="color-option <?php 
        echo $color == $current_color ? 'selected' : '';
        ?>
">
				<input name="admin_color" id="admin_color_<?php 
        echo esc_attr($color);
        ?>
" type="radio" value="<?php 
        echo esc_attr($color);
        ?>
" class="tog" <?php 
        checked($color, $current_color);
        ?>
 />
				<input type="hidden" class="css_url" value="<?php 
        echo esc_url($color_info->url);
        ?>
" />
				<input type="hidden" class="icon_colors" value="<?php 
        echo esc_attr(hq_json_encode(array('icons' => $color_info->icon_colors)));
        ?>
" />
				<label for="admin_color_<?php 
        echo esc_attr($color);
        ?>
"><?php 
        echo esc_html($color_info->name);
        ?>
</label>
				<table class="color-palette">
					<tr>
					<?php 
        foreach ($color_info->colors as $html_color) {
            ?>
						<td style="background-color: <?php 
            echo esc_attr($html_color);
            ?>
">&nbsp;</td>
						<?php 
        }
        ?>
					</tr>
				</table>
			</div>
			<?php 
    }
    ?>
	</fieldset>
	<?php 
}
Example #5
0
    /**
     * Display second step of custom header image page.
     *
     * @since 0.0.1
     */
    public function step_2()
    {
        check_admin_referer('custom-header-upload', '_hqnonce-custom-header-upload');
        if (!current_theme_supports('custom-header', 'uploads')) {
            hq_die(__('Cheatin&#8217; uh?'), 403);
        }
        if (empty($_POST) && isset($_GET['file'])) {
            $attachment_id = absint($_GET['file']);
            $file = get_attached_file($attachment_id, true);
            $url = hq_get_attachment_image_src($attachment_id, 'full');
            $url = $url[0];
        } elseif (isset($_POST)) {
            $data = $this->step_2_manage_upload();
            $attachment_id = $data['attachment_id'];
            $file = $data['file'];
            $url = $data['url'];
        }
        if (file_exists($file)) {
            list($width, $height, $type, $attr) = getimagesize($file);
        } else {
            $data = hq_get_attachment_metadata($attachment_id);
            $height = isset($data['height']) ? $data['height'] : 0;
            $width = isset($data['width']) ? $data['width'] : 0;
            unset($data);
        }
        $max_width = 0;
        // For flex, limit size of image displayed to 1500px unless theme says otherwise
        if (current_theme_supports('custom-header', 'flex-width')) {
            $max_width = 1500;
        }
        if (current_theme_supports('custom-header', 'max-width')) {
            $max_width = max($max_width, get_theme_support('custom-header', 'max-width'));
        }
        $max_width = max($max_width, get_theme_support('custom-header', 'width'));
        // If flexible height isn't supported and the image is the exact right size
        if (!current_theme_supports('custom-header', 'flex-height') && !current_theme_supports('custom-header', 'flex-width') && $width == get_theme_support('custom-header', 'width') && $height == get_theme_support('custom-header', 'height')) {
            // Add the meta-data
            if (file_exists($file)) {
                hq_update_attachment_metadata($attachment_id, hq_generate_attachment_metadata($attachment_id, $file));
            }
            $this->set_header_image(compact('url', 'attachment_id', 'width', 'height'));
            /**
             * Fires after the header image is set or an error is returned.
             *
             * @since 0.0.1
             *
             * @param string $file          Path to the file.
             * @param int    $attachment_id Attachment ID.
             */
            do_action('hq_create_file_in_uploads', $file, $attachment_id);
            // For replication
            return $this->finished();
        } elseif ($width > $max_width) {
            $oitar = $width / $max_width;
            $image = hq_crop_image($attachment_id, 0, 0, $width, $height, $max_width, $height / $oitar, false, str_replace(basename($file), 'midsize-' . basename($file), $file));
            if (!$image || is_hq_error($image)) {
                hq_die(__('Image could not be processed. Please go back and try again.'), __('Image Processing Error'));
            }
            /** This filter is documented in hq-admin/custom-header.php */
            $image = apply_filters('hq_create_file_in_uploads', $image, $attachment_id);
            // For replication
            $url = str_replace(basename($url), basename($image), $url);
            $width = $width / $oitar;
            $height = $height / $oitar;
        } else {
            $oitar = 1;
        }
        ?>

<div class="wrap">
<h1><?php 
        _e('Crop Header Image');
        ?>
</h1>

<form method="post" action="<?php 
        echo esc_url(add_query_arg('step', 3));
        ?>
">
	<p class="hide-if-no-js"><?php 
        _e('Choose the part of the image you want to use as your header.');
        ?>
</p>
	<p class="hide-if-js"><strong><?php 
        _e('You need JavaScript to choose a part of the image.');
        ?>
</strong></p>

	<div id="crop_image" style="position: relative">
		<img src="<?php 
        echo esc_url($url);
        ?>
" id="upload" width="<?php 
        echo $width;
        ?>
" height="<?php 
        echo $height;
        ?>
" />
	</div>

	<input type="hidden" name="x1" id="x1" value="0"/>
	<input type="hidden" name="y1" id="y1" value="0"/>
	<input type="hidden" name="width" id="width" value="<?php 
        echo esc_attr($width);
        ?>
"/>
	<input type="hidden" name="height" id="height" value="<?php 
        echo esc_attr($height);
        ?>
"/>
	<input type="hidden" name="attachment_id" id="attachment_id" value="<?php 
        echo esc_attr($attachment_id);
        ?>
" />
	<input type="hidden" name="oitar" id="oitar" value="<?php 
        echo esc_attr($oitar);
        ?>
" />
	<?php 
        if (empty($_POST) && isset($_GET['file'])) {
            ?>
	<input type="hidden" name="create-new-attachment" value="true" />
	<?php 
        }
        ?>
	<?php 
        hq_nonce_field('custom-header-crop-image');
        ?>

	<p class="submit">
	<?php 
        submit_button(__('Crop and Publish'), 'primary', 'submit', false);
        ?>
	<?php 
        if (isset($oitar) && 1 == $oitar && (current_theme_supports('custom-header', 'flex-height') || current_theme_supports('custom-header', 'flex-width'))) {
            submit_button(__('Skip Cropping, Publish Image as Is'), 'secondary', 'skip-cropping', false);
        }
        ?>
	</p>
</form>
</div>
		<?php 
    }
Example #6
0
/**
 * Output nonce, action, and option_page fields for a settings page.
 *
 * @since 0.0.1
 *
 * @param string $option_group A settings group name. This should match the group name used in register_setting().
 */
function settings_fields($option_group)
{
    echo "<input type='hidden' name='option_page' value='" . esc_attr($option_group) . "' />";
    echo '<input type="hidden" name="action" value="update" />';
    hq_nonce_field("{$option_group}-options");
}