示例#1
0
文件: api.php 项目: 2030449c/farkol
    public function theme_activated()
    {
        /* Define some constants relevant to theme activation if not already set in functions.php. */
        if (!defined('PC_INSTALL_DEFAULT_CONTENT')) {
            /* Installs default content if set to TRUE. */
            define('PC_INSTALL_DEFAULT_CONTENT', FALSE);
        }
        if (!defined('PC_INSTALL_CONTENT_PROMPT')) {
            /* Installs default content automatically if FALSE. Otherwise prompts user first. */
            define('PC_INSTALL_CONTENT_PROMPT', TRUE);
        }
        if (!defined('PC_INSTALL_DEMO_CONTENT')) {
            /* Installs site specific special default content for demo purposes. */
            define('PC_INSTALL_DEMO_CONTENT', FALSE);
        }
        if (current_user_can('edit_theme_options')) {
            /* Get rid of the default WordPress notice upon theme activation. */
            ?>
			<script type="text/javascript">
				jQuery(document).ready(function($) {
					$('#message2').css('display', 'none');
				});
			</script>

			<?php 
            $theme_options_url = 'themes.php?page=' . PC_THEME_MENU_SLUG;
            $install_content = 'themes.php?activated=true&install_default_content=true';
            /* If TRUE, install default content. */
            if (PC_INSTALL_DEFAULT_CONTENT) {
                if (isset($_POST['install_default_content'])) {
                    PC_Utility::install_default_content($theme_options_url);
                } else {
                    /* If TRUE, prompt to install default content first. */
                    if (PC_INSTALL_CONTENT_PROMPT) {
                        ?>
						<div class="updated" style="margin-top: 10px;padding-bottom:10px;">
							<?php 
                        echo '<h3 style="margin: 0.7em 0;padding-top: 5px;">Congratulations, ' . PC_THEME_NAME . ' successfully activated!</h3>For new sites we have created a content starter kit which automatically installs some default content for you,  including:';
                        ?>
							<ul>
							<li><strong>Pages</strong> - Blog, About Us, Sitemap, Contact Us pages created.</li>
							<li><strong>Navigation Menu</strong> - Pages added to the main navigation menu, along with a home page link.</li>
							</ul>
							Note: If you have an established site you may want to just go straight to the theme options page.<br /><br />
							<form id="pc-install_content" method="post" action="<?php 
                        echo admin_url($install_content);
                        ?>
">
								<span>
									<input class="button-primary" type="submit" value="Install Default Content" name="create_content" onclick="return confirm('Are you sure? Site content will be modified.');">
									<a class="button" href="<?php 
                        echo admin_url($theme_options_url);
                        ?>
"><?php 
                        echo PC_THEME_NAME;
                        ?>
 Theme Options</a>
									<input type="hidden" value="true" name="install_default_content">
								</span>
							</form>
						</div>
						<?php 
                    } else {
                        PC_Utility::install_default_content($theme_options_url);
                    }
                }
            } else {
                PC_Utility::theme_activation_message($theme_options_url);
            }
        } else {
            ?>
			<div class="updated"><p><?php 
            printf(PC_THEME_NAME . ' theme activated! <a href="%s">Visit Site</a>', home_url());
            ?>
</p></div><?php 
        }
    }