Example #1
0
/**
 * This function generates the theme's options page in WordPress administration.
 *
 * @package Franz Josef
 * @since Franz Josef 1.0
*/
function franz_options()
{
    global $franz_settings, $franz_defaults;
    /* Checks if the form has just been submitted */
    if (!isset($_REQUEST['settings-updated'])) {
        $_REQUEST['settings-updated'] = false;
    }
    /* Import the franz theme options */
    if (isset($_POST['franz_import'])) {
        franz_import_form();
        return;
    }
    if (isset($_POST['franz_import_confirmed'])) {
        franz_import_file();
        return;
    }
    /* Reset theme settings  */
    require FRANZ_ROOTDIR . '/admin/options-presets.php';
    /* Uninstall the theme if confirmed */
    if (isset($_POST['franz_uninstall_confirmed'])) {
        include FRANZ_ROOTDIR . '/admin/uninstall.php';
    }
    /* Display a confirmation page to uninstall the theme */
    if (isset($_POST['franz_uninstall'])) {
        ?>

		<div class="wrap">
        <div class="icon32" id="icon-themes"><br /></div>
        <h2><?php 
        _e('Uninstall Franz Josef', 'franz-josef');
        ?>
</h2>
        <p><?php 
        _e("Please confirm that you would like to uninstall the Franz Josef theme. All of the theme's options in the database will be deleted.", 'franz-josef');
        ?>
</p>
        <p><?php 
        _e('This action is not reversible.', 'franz-josef');
        ?>
</p>
        <form action="" method="post">
        	<?php 
        wp_nonce_field('franz-uninstall', 'franz-uninstall');
        ?>
        	<input type="hidden" name="franz_uninstall_confirmed" value="true" />
            <input type="submit" class="button franz_uninstall" value="<?php 
        _e('Uninstall Theme', 'franz-josef');
        ?>
" />
        </form>
        </div>
        
		<?php 
        return;
    }
    /* Get the updated settings before outputting the options page */
    $franz_settings = franz_get_settings();
    /* This where we start outputting the options page */
    ?>
	<div class="wrap meta-box-sortables">
		<div class="icon32" id="icon-themes"><br /></div>
        <h2><?php 
    _e('Franz Josef Theme Options', 'franz-josef');
    ?>
</h2>
        
        <p><?php 
    _e('These are the global settings for the theme. You may override some of the settings in individual posts and pages.', 'franz-josef');
    ?>
</p>
        
		<?php 
    settings_errors('franz_options');
    ?>
        
        
        <?php 
    /* Print the options tabs */
    ?>
        <?php 
    if ($_GET['page'] == 'franz_options') {
        $current_tab = isset($_GET['tab']) ? $_GET['tab'] : 'general';
        franz_options_tabs($current_tab, $franz_settings['options_tabs']);
    }
    ?>
        
        <div class="left-wrap">
        
        <?php 
    if (!in_array($current_tab, array('addons', 'about'))) {
        ?>
        <form method="post" action="options.php" class="mainform clearfix" id="franz-options-form">
		
            <?php 
        /* Output wordpress hidden form fields, e.g. nonce etc. */
        ?>
            <?php 
        settings_fields('franz_options');
        ?>
        
            <?php 
        /* Display the current tab */
        ?>
            <?php 
        franz_options_tabs_content($current_tab);
        ?>
    
            
            <?php 
        /* The form submit button */
        ?>
            <p class="submit"><input type="submit" class="button-primary" id="franz-save-options" value="<?php 
        _e('Save Options', 'franz-josef');
        ?>
" /></p>
        
        </form>
        <?php 
    } else {
        franz_options_tabs_content($current_tab);
        ?>
        <?php 
    }
    ?>
        
        <div class="franz-ajax-response"></div>
        
        </div><!-- #left-wrap -->
        
        <div class="side-wrap">
        
        
        <?php 
    /* Franz Josef theme news RSS feed */
    ?>
        <div class="postbox franz-news no-toggle">
            <div>
        		<h3 class="hndle"><?php 
    _e('Franz Josef news', 'franz-josef');
    ?>
</h3>
            </div>
            <div class="panel-wrap inside">
                <?php 
    $franz_news = fetch_feed(array('http://www.graphene-theme.com/category/franz-josef/feed/rss2/'));
    if (!is_wp_error($franz_news)) {
        $maxitems = $franz_news->get_item_quantity(3);
        $news_items = $franz_news->get_items(0, $maxitems);
        ?>
					<ol class="franz-news-list">
						<?php 
        if ($maxitems == 0) {
            echo '<li>' . __('No news items.', 'franz-josef') . '</li>';
        } else {
            foreach ($news_items as $news_item) {
                ?>
							<li>
								<a href='<?php 
                echo esc_url($news_item->get_permalink());
                ?>
'><?php 
                echo esc_html($news_item->get_title());
                ?>
</a><br />
								<?php 
                echo esc_html(franz_truncate_words(strip_tags($news_item->get_description()), 20, ' [...]'));
                ?>
<br />
								<span class="news-item-date"><?php 
                echo 'Posted on ' . $news_item->get_date('j F Y, g:i a');
                ?>
</span>
							</li>
						<?php 
            }
        }
        ?>
					</ol>
                <?php 
    } else {
        ?>
					<div class="feed-error">
                    	<?php 
        foreach ($franz_news->get_error_message() as $error) {
            ?>
                        	<p><?php 
            echo $error;
            ?>
</p>
                        <?php 
        }
        ?>
                    </div>
				<?php 
    }
    ?>
            </div>
        </div>
            
        
        <?php 
    /* Options Presets. This uses separate form than the main form */
    ?>
        <div class="postbox preset non-essential-option">
            <div class="head-wrap">
                <div title="<?php 
    _e('Click to toggle', 'franz-josef');
    ?>
" class="handlediv"><br /></div>
                <h3 class="hndle"><?php 
    _e('Reset settings', 'franz-josef');
    ?>
</h3>
            </div>
            <div class="panel-wrap inside">
                <p><?php 
    _e('Reset all of the theme\'s settings to their default values. Only settings accessible via Franz Josef Options are affected. Custom Header, Custom Menus, and other WordPress settings won\'t be affected.', 'franz-josef');
    ?>
</p>
                <p><?php 
    _e('<strong>WARNING:</strong> This action is not reversible.', 'franz-josef');
    ?>
</p>
                <form action="" method="post">
                    <?php 
    wp_nonce_field('franz-preset', 'franz-preset');
    ?>
                    <input type="hidden" name="franz_options_preset" value="reset" id="franz_options_preset-reset" />
                    <input type="hidden" name="franz_preset" value="true" />
                    <input type="submit" class="button-primary franz_preset" value="<?php 
    _e('Reset settings', 'franz-josef');
    ?>
" />
                </form>
            </div>
        </div>
        
        
        <?php 
    /* Theme import/export */
    ?>
    
        <div class="postbox non-essential-option">
            <div class="head-wrap">
                <div title="<?php 
    _e('Click to toggle', 'franz-josef');
    ?>
" class="handlediv"><br /></div>
        		<h3 class="hndle"><?php 
    _e('Import/export theme options', 'franz-josef');
    ?>
</h3>
            </div>
            <div class="panel-wrap inside">
                <p><strong><?php 
    _e('Import', 'franz-josef');
    ?>
</strong></p>    
                <form action="" method="post">
                    <input type="hidden" name="franz_import" value="true" />
                    <button type="submit" class="button"><i class="fa fa-upload" style="font-size:16px;margin-right:5px;"></i> <?php 
    _e('Import theme options', 'franz-josef');
    ?>
</button>
                </form> <br />
                <p><strong><?php 
    _e('Export', 'franz-josef');
    ?>
</strong></p>                
                <form action="" method="post">
                	<?php 
    wp_nonce_field('franz-export', 'franz-export');
    ?>
                    <input type="hidden" name="franz_export" value="true" />
                    <button type="submit" class="button"><i class="fa fa-download" style="font-size:16px;margin-right:5px;"></i> <?php 
    _e('Export theme options', 'franz-josef');
    ?>
</button>
                </form>              
            </div>
        </div>
            
        
        <?php 
    /* Theme's uninstall */
    ?>
        <div class="postbox non-essential-option">
            <div class="head-wrap">
                <div title="<?php 
    _e('Click to toggle', 'franz-josef');
    ?>
" class="handlediv"><br /></div>
        		<h3 class="hndle"><?php 
    _e('Uninstall theme', 'franz-josef');
    ?>
</h3>
            </div>
            <div class="panel-wrap inside">
                <p><?php 
    _e("<strong>Be careful!</strong> Uninstalling the theme will remove all of the theme's options from the database. Do this only if you decide not to use the theme anymore.", 'franz-josef');
    ?>
</p>
                <p><?php 
    _e('If you just want to try another theme, there is no need to uninstall this theme. Simply activate the other theme in the Appearance &gt; Themes admin page.', 'franz-josef');
    ?>
</p>
                <p><?php 
    _e("Note that uninstalling this theme <strong>does not remove</strong> the theme's files. To delete the files after you have uninstalled this theme, go to Appearance &gt; Themes and delete the theme from there.", 'franz-josef');
    ?>
</p>
                <form action="" method="post">
                    <?php 
    wp_nonce_field('franz-options', 'franz-options');
    ?>
                
                    <input type="hidden" name="franz_uninstall" value="true" />
                    <input type="submit" class="button-primary franz_uninstall" value="<?php 
    _e('Uninstall Theme', 'franz-josef');
    ?>
" />
                </form>
            </div>
        </div>
        
        
         </div><!-- #side-wrap -->
    </div><!-- #wrap -->
    
    
<?php 
}
Example #2
0
            
            <?php 
$args = array('user_id' => $user_id, 'status' => 'approve');
$comments = get_comments(apply_filters('franz_user_comment_args', $args));
if ($comments) {
    shuffle($comments);
    $i = 0;
    $count = count($comments);
    $comment = $comments[$i];
    while (strlen($comment->comment_content) > 100 && $i < $count) {
        $i++;
        $comment = $comments[$i];
    }
    if (!$comment) {
        $comment = $comments[0];
        $comment->comment_content = franz_truncate_words($comment->comment_content, 25);
    }
    ?>
                <div class="featured-comment">
                    <blockquote>
                        <?php 
    echo wpautop($comment->comment_content);
    ?>
                        <cite><?php 
    printf(__('Commented on %s.', 'franz-josef'), '<a href="' . esc_url(get_permalink($comment->comment_post_ID)) . '">' . get_the_title($comment->comment_post_ID) . '</a>');
    ?>
 </cite>
                    </blockquote>
                    <?php 
    do_action('franz_author_featured_comment');
    ?>