Create Menu on Theme Activation – WordPress

add_action(‘after_switch_theme’, ‘theme_activation_function’, 10 ,  2); function theme_activation_function ($oldname, $oldtheme = false) { /* Create header and footer menus */   $menus = array(     ‘Primary Menu’  => array(       ‘about-us’  => ‘About Us’,        ‘services’  => ‘Services’,        ‘templates-forms’  => ‘Templates & Forms’,        ‘clients’  => ‘Clients’,        ‘price-quote’  => ‘Price Quote’     ),   ‘Top Menu’ => array(     ‘home’ => ‘Home’,      ‘contact’ => ‘Contact’,      ‘sitemap’ => ‘Sitemap’   ),   ‘Footer Menu’ => array(     ‘terms-of-use’ => ‘Terms of Use’,      ‘privacy-policy’ => ‘Privacy Policy’   ) ); foreach($menus as $menuname => $menuitems) {   $menu_exists = wp_get_nav_menu_object($menuname);   // If it doesn’t exist, let’s create it.   if ( !$menu_exists) {     $menu_id = wp_create_nav_menu($menuname);     foreach($menuitems as $slug => $item) {       wp_update_nav_menu_item(       $menu_id, 0, array(             ‘menu-item-title’  => $item,             ‘menu-item-object’  => ‘page’,        … Continue reading Create Menu on Theme Activation – WordPress

Displaying a different theme for each day of the week drupal

<?php /** * Implements hook_custom_theme(). */ function mymodule_custom_theme() { // An array of themes for each day of the week. // These themes have to be installed and enabled. $themes = array(); $themes[0] = ‘monday_theme’; $themes[1] = ‘tuesday_theme’; .. // Get the current day of the week in numerical form. $day = date(“w”); // Override… Continue reading Displaying a different theme for each day of the week drupal

Add a new region to theme programmatically in Drupal

/** * Implements hook_system_info_alter() * Adds a new “tray” region to the current theme */ function MODULE_system_info_alter(&$info, $file){ global $custom_theme; // If non-default theme configuration has been selected, set the custom theme. $custom_theme = isset ($theme) ? $theme : variable_get(‘theme_default’, ‘bartik’); if ($file->name == $custom_theme){ $info[‘regions’] = array_merge($info[‘regions’], array(‘tray’ => t(‘Tray’))); } }