Guest User

loading.php

a guest
Feb 28th, 2013
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 36.13 KB | None | 0 0
  1. <?php
  2. #-----------------------------------------
  3. #   RT-Theme loading.php
  4. #   version: 1.0
  5. #-----------------------------------------
  6.  
  7. #
  8. #   Load the theme
  9. #
  10.  
  11. class RTTheme{
  12.      
  13.     //Cufon Font Files
  14.     public $fonts=array(
  15.                 "Aller_Light_400.font"         =>  array("Aller Light","Aller Light"),
  16.                 "bebas-neue.cufonfonts"        =>  array("Bebas Neue","Bebas Neue"),
  17.                 "Cicle_400.font"               => array("Cicle","Cicle"),
  18.                 "Comfortaa.font"               => array("Comfortaa","Comfortaa"),
  19.                 "ColaborateLight_400.font"     => array("ColaborateLight","Colaborate Light"),
  20.                 "Diavlo.font"                  => array("Diavlo","Diavlo"),
  21.                 "Droid_Serif_400.font"         => array("Droid Serif","Droid Serif"),  
  22.                 "PT_Sans_400.font"             => array("PT Sans","PT Sans"),
  23.                 "Museo.font"                   => array("Museo","Museo Normal"),
  24.                 "Museo.light.font"             => array("Museo Light","Museo Light"),
  25.                 "Sansation.light.font"         => array("Sansation Light","Sansation Light"),
  26.                 "Sansation.font"               => array("Sansation","Sansation Normal"),
  27.                 "TitilliumText22L_Lt_300.font" => array("TitilliumText22L Lt","Titillium Text"),
  28.                 "Vegur_300.font"               => array("Vegur-Light","Vegur Light"),  
  29.                 );
  30.    
  31.     //Google Font Files
  32.     public $google_fonts=array(
  33.                 "Changa+One" => array("Changa One","Changa One"),
  34.                 "Dosis:700&subset=latin,latin-ext" => array("Dosis","Dosis"),
  35.                 "Open+Sans:400,400italic&subset=latin,latin-ext" => array("Open Sans","Open Sans - Latin"),
  36.                 "Open+Sans:400,400italic&subset=latin,latin-ext,greek-ex" => array("Open Sans","Open Sans - Greek"),
  37.                 "Open+Sans:400,400italic&subset=latin,latin-ext,cyrillic-ext"    => array("Open Sans","Open Sans - Cyrillic"),
  38.                 "Open+Sans:400,400italic&subset=latin,latin-ext,vietnames" => array("Open Sans","Open Sans - Vietnames"),
  39.                 "Open+Sans+Condensed:300,700,300italic&subset=latin,latin-ext" => array("Open Sans Condensed","Open Sans Condensed - Latin"),
  40.                 "Open+Sans+Condensed:300,700,300italic&subset=latin,latin-ext,greek-ex" => array("Open Sans Condensed","Open Sans Condensed- Greek"),
  41.                 "Open+Sans+Condensed:300,700,300italic&subset=latin,latin-ext,cyrillic-ext"  => array("Open Sans Condensed","Open Sans Condensed- Cyrillic"),
  42.                 "Open+Sans+Condensed:300,700,300italic&subset=latin,latin-ext,vietnames" => array("Open Sans Condensed","Open Sans Condensed- Vietnames"),
  43.                 "Lora"               => array("Lora","Lora"),
  44.                 "Nunito"                 => array("Nunito","Nunito"),
  45.                 "Francois+One&subset=latin,latin-ext" => array("Francois One","Francois One"),
  46.                 "Play:400,700&subset=latin,latin-ext"                => array("Play","Play - Latin"),
  47.                 "Play:400,700&subset=latin,latin-ext,greek-ext"              => array("Play","Play - Greek"),
  48.                 "Play:400,700&subset=latin,latin-ext,cyrillic-ext"               => array("Play","Play - Cyrillic"),
  49.                 "Bitter:400,700,400italic&subset=latin,latin-ext"                => array("Bitter","Bitter"),
  50.                 "Shadows+Into+Light"                 => array("Shadows Into Light","Shadows Into Light"),
  51.                 "Marck+Script&subset=latin,latin-ext"                => array("Marck Script","Marck Script - Lation"),
  52.                 "Marck+Script&subset=latin,latin-ext,cyrillic-ext"               => array("Marck Script","Marck Script - Cyrillic"),
  53.                 "Questrial"              => array("Questrial","Questrial"),
  54.                 "Fredoka+One"                => array("Fredoka One","Fredoka One"),
  55.                 "Righteous&subset=latin,latin-ext"               => array("Righteous","Righteous"),
  56.                 "Ruda&subset=latin,latin-ext"    => array("Ruda","Ruda"),
  57.                 "Squada+One"                 => array("Squada One","Squada One"),
  58.                 "Exo&subset=latin,latin-ext"   => array("Exo","Exo"),              
  59.                 "Cabin+Condensed"              => array("Cabin Condensed","Cabin Condensed"),
  60.                 "Cagliostro"                   => array("Cagliostro","Cagliostro"),
  61.                 "Lemon"                        => array("Lemon","Lemon"),
  62.                 "Aguafina+Script"              => array("Aguafina Script","Aguafina Script"),
  63.                 "Iceland"                      => array("Iceland","Iceland"),
  64.                 "Signika"                      => array("Signika","Signika"),
  65.                 "Prociono"                     => array("Prociono","Prociono"),
  66.                 "Arapey"                       => array("Arapey","Arapey"),
  67.                 "Convergence"                  => array("Convergence","Convergence"),
  68.                 "Rammetto+One"                 => array("Rammetto One","Rammetto One"),
  69.                 "Linden+Hill"                  => array("Linden Hill","Linden Hill"),
  70.                 "Dorsa"                        => array("Dorsa","Dorsa"),
  71.                 "Merienda+One"                 => array("Merienda One","Merienda One"),
  72.                 "Petrona"                      => array("Petrona","Petrona"),
  73.                 "Nova+Square"                  => array("Nova Square","Nova Square"),
  74.                 "Jockey+One"                   => array("Jockey One","Jockey One"),
  75.                 "Antic"                        => array("Antic","Antic"),
  76.                 "Abel"                         => array("Abel","Abel"),
  77.                 "Nova+Flat"                    => array("Nova Flat","Nova Flat"),
  78.                 "Sansita+One"                  => array("Sansita One","Sansita One"),
  79.                 "Marvel"                       => array("Marvel","Marvel"),
  80.                 "Ubuntu+Condensed"             => array("Ubuntu Condensed","Ubuntu Condensed"),
  81.                 "Rationale"                    => array("Rationale","Rationale"),
  82.                 "Anton"                        => array("Anton","Anton"),
  83.                 "Michroma"                     => array("Michroma","Michroma"),
  84.                 "Paytone+One"                  => array("Paytone One","Paytone One"),
  85.                 "Expletus+Sans"                => array("Expletus Sans","Expletus Sans"),
  86.                 "Orbitron"                     => array("Orbitron","Orbitron"),
  87.                 "Gruppo"                       => array("Gruppo","Gruppo"),
  88.                 "Chewy"                        => array("Chewy","Chewy"),
  89.                 "Wire+One"                     => array("Wire One","Wire One"),
  90.                 "Aclonica"                     => array("Aclonica","Aclonica"),
  91.                 "Damion"                       => array("Damion","Damion"),
  92.                 "Swanky+and+Moo+Moo"           => array("Swanky and Moo Moo","Swanky and Moo Moo"),
  93.                 "News+Cycle"                   => array("News Cycle","News Cycle"),
  94.                 "Over+the+Rainbow"             => array("Over the Rainbow","Over the Rainbow"),
  95.                 "Wallpoet"                     => array("Wallpoet","Wallpoet"),
  96.                 "Special+Elite"                => array("Special Elite", "Special Elite"),
  97.                 "MedievalSharp"                => array("MedievalSharp","MedievalSharp"),
  98.                 "Waiting+for+the+Sunrise"      => array("Waiting for the Sunrise","Waiting for the Sunrise"),
  99.                 "Quattrocento+Sans"            => array("Quattrocento Sans","Quattrocento Sans"),
  100.                 "The+Girl+Next+Door"           => array("The Girl Next Door","The Girl Next Door"),
  101.                 "Nova+Slim"                    => array("Nova Slim","Nova Slim"),
  102.                 "Smythe"                       => array("Smythe","Smythe"),
  103.                 "Miltonian+Tattoo"             => array("Miltonian Tattoo","Miltonian Tattoo"),
  104.                 "Kristi"                       => array("Kristi","Kristi"),
  105.                 "Sue+Ellen+Francisco"          => array("Sue Ellen Francisco","Sue Ellen Francisco"),
  106.                 "Bangers"                      => array("Bangers","Bangers"),
  107.                 "Terminal+Dosis+Light"         => array("Terminal Dosis Light","Terminal Dosis Light"),
  108.                 "Annie+Use+Your+Telescope"     => array("Annie Use Your Telescope","Annie Use Your Telescope"),
  109.                 "EB+Garamond&subset=latin,latin-ext"              => array("EB Garamond","EB Garamond"),
  110.                 "EB+Garamond&subset=cyrillic,latin"     => array("EB Garamond","EB Garamond Cyrillic"),
  111.                 "Irish+Grover"                 => array("Irish Grover","Irish Grover"),
  112.                 "Dawning+of+a+New+Day"         => array("Dawning of a New Day","Dawning of a New Day"),
  113.                 "Crimson+Text"                 => array("Crimson Text","Crimson Text"),
  114.                 "Quattrocento"                 => array("Quattrocento","Quattrocento"),
  115.                 "Expletus+Sans"                => array("Expletus Sans","Expletus Sans"),
  116.                 "Maiden+Orange"                => array("Maiden Orange","Maiden Orange"),
  117.                 "Sniglet:800"                  => array("Sniglet","Sniglet"),
  118.                 "Astloch"                      => array("Astloch","Astloch"),
  119.                 "Pacifico"                     => array("Pacifico","Pacifico"),
  120.                 "Indie+Flower"                 => array("Indie Flower","Indie Flower"),
  121.                 "VT323"                        => array("VT323","VT323"),
  122.                 "Vollkorn"                     => array("Vollkorn","Vollkorn"),
  123.                 "Architects+Daughter"          => array("Architects Daughter","Architects Daughter"),
  124.                 "Michroma"                     => array("Michroma","Michroma"),
  125.                 "Anton"                        => array("Anton","Anton"),
  126.                 "Bevan"                        => array("Bevan","Bevan"),
  127.                 "Allan:bold"                   => array("Allan","Allan"),
  128.                 "Kenia"                        => array("Kenia","Kenia"),
  129.                 "Six+Caps"                     => array("Six Caps","Six Caps"),
  130.                 "Lekton"                       => array("Lekton","Lekton"),
  131.                 "UnifrakturMaguntia"           => array("UnifrakturMaguntia","UnifrakturMaguntia"),
  132.                 "Oswald&subset=latin,latin-ext"                    => array("Oswald","Oswald"),
  133.                 "League+Script"                => array("League Script","League Script"),
  134.                 "Orbitron"                     => array("Orbitron","Orbitron"),
  135.                 "Cuprum"                       => array("Cuprum","Cuprum"),
  136.                 "Cabin"                        => array("Cabin","Cabin"),
  137.                 "Philosopher"                  => array("Philosopher","Philosopher"),
  138.                 "Walter+Turncoat"              => array("Walter Turncoat","Walter Turncoat"),
  139.                 "Candal"                       => array("Candal","Candal"),
  140.                 "Cabin+Sketch:bold"            => array("Cabin Sketch","Cabin Sketch"),
  141.                 "Droid+Sans+Mono"              => array("Droid Sans Mono","Droid Sans Mono"),
  142.                 "Calligraffitti"               => array("Calligraffitti","Calligraffitti"),
  143.                 "Neucha"                       => array("Neucha","Neucha"),
  144.                 "Rock+Salt"                    => array("Rock Salt","Rock Salt"),
  145.                 "Lato"                         => array("Lato","Lato"),
  146.                 "Luckiest+Guy"                 => array("Luckiest Guy","Luckiest Guy"),
  147.                 "Mountains+of+Christmas"       => array("Mountains of Christmas","Mountains of Christmas"),
  148.                 "Raleway:100"                  => array("Raleway","Raleway"),
  149.                 "Geo"                          => array("Geo","Geo"),
  150.                 "Slackey"                      => array("Slackey","Slackey"),
  151.                 "Corben:bold"                  => array("Corben","Corben"),
  152.                 "Unkempt"                      => array("Unkempt","Unkempt"),
  153.                 "Droid+Sans:400,700&v2"        => array("Droid Sans","Droid Sans"),
  154.                 "Cherry+Cream+Soda"            => array("Cherry Cream Soda","Cherry Cream Soda"),
  155.                 "Vibur"                        => array("Vibur","Vibur"),
  156.                 "Gruppo"                       => array("Gruppo","Gruppo"),
  157.                 "Permanent+Marker"             => array("Permanent Marker","Permanent Marker"),
  158.                 "Coda:800"                     => array("Coda","Coda"),
  159.                 "Cousine"                      => array("Cousine","Cousine"),
  160.                 "Crafty+Girls"                 => array("Crafty Girls","Crafty Girls"),
  161.                 "Schoolbell"                   => array("Schoolbell","Schoolbell"),
  162.                 "Kranky"                       => array("Kranky","Kranky"),
  163.                 "Covered+By+Your+Grace"        => array("Covered By Your Grace","Covered By Your Grace"),
  164.                 "Syncopate"                    => array("Syncopate","Syncopate"),
  165.                 "PT+Serif"                     => array("PT Serif","PT Serif"),            
  166.                 "PT+Serif&subset=cyrillic,latin" => array("PT Serif","PT Serif Cyrillic"),
  167.                 "Josefin+Sans"                 => array("Josefin Sans","Josefin Sans"),
  168.                 "Homemade+Apple"               => array("Homemade Apple","Homemade Apple"),
  169.                 "Molengo"                      => array("Molengo","Molengo"),
  170.                 "Yanone+Kaffeesatz"            => array("Yanone Kaffeesatz","Yanone Kaffeesatz"),
  171.                 "Radley"                       => array("Radley","Radley"),
  172.                 "Chewy"                        => array("Chewy","Chewy"),
  173.                 "Neuton"                       => array("Neuton","Neuton"),
  174.                 "Tinos"                        => array("Tinos","Tinos"),
  175.                 "Tangerine"                    => array("Tangerine","Tangerine"),
  176.                 "Allerta"                      => array("Allerta","Allerta"),
  177.                 "PT+Sans:400,700,400italic"    => array("PT Sans","PT Sans"),
  178.                 "PT+Sans+Narrow&subset=cyrillic,latin" => array("PT Sans Narrow","PT Sans Narrow Cyrillic"),
  179.                 "Inconsolata"                  => array("Inconsolata","Inconsolata"),
  180.                 "Droid+Serif:400,400italic,700,700italic" => array("Droid Serif","Droid Serif"),
  181.                 "Sunshiney"                    => array("Sunshiney","Sunshiney"),
  182.                 "Bentham"                      => array("Bentham","Bentham"),
  183.                 "Just+Another+Hand"            => array("Just Another Hand","Just Another Hand"),
  184.                 "Cardo"                        => array("Cardo","Cardo"),
  185.                 "Cantarell"                    => array("Cantarell","Cantarell"),
  186.                 "OFL+Sorts+Mill+Goudy+TT"      => array("OFL Sorts Mill Goudy TT","OFL Sorts Mill Goudy TT"),
  187.                 "Ubuntu"                       => array("Ubuntu","Ubuntu"),
  188.                 "Ubuntu&subset=greek,latin"    => array("Ubuntu","Ubuntu Greek"),
  189.                 "Ubuntu&subset=cyrillic,latin" => array("Ubuntu","Ubuntu Cyrillic"),   
  190.                 "Reenie+Beanie"                => array("Reenie Beanie","Reenie Beanie"),
  191.                 "Arvo"                         => array("Arvo","Arvo"),
  192.                 "Coming+Soon"                  => array("Coming Soon","Coming Soon"),
  193.                 "Josefin+Slab"                 => array("Josefin Slab","Josefin Slab"),
  194.                 "Fontdiner+Swanky"             => array("Fontdiner Swanky","Fontdiner Swanky"),
  195.                 "Old+Standard+TT"              => array("Old Standard TT","Old Standard TT"),
  196.                 "Puritan"                      => array("Puritan","Puritan"),
  197.                 "Merriweather"                 => array("Merriweather","Merriweather"),
  198.                 "UnifrakturCook:bold"          => array("UnifrakturCook","UnifrakturCook"),
  199.                 "Crushed"                      => array("Crushed","Crushed"),
  200.                 "Buda:light"                   => array("Buda","Buda"),
  201.                 "IM+Fell+Great+Primer"         => array("IM Fell Great Primer","IM Fell Great Primer"),                    
  202.                 "Goudy+Bookletter+1911"        => array("Goudy Bookletter 1911","Goudy Bookletter 1911"),
  203.                 "Nobile"                       => array("Nobile","Nobile"),
  204.                 "Copse"                        => array("Copse","Copse"),
  205.                 "Lobster"                      => array("Lobster","Lobster"),
  206.                 "Allerta+Stencil"              => array("Allerta Stencil","Allerta Stencil"),
  207.                 "Arimo"                        => array("Arimo","Arimo"),
  208.                 "Meddon"                       => array("Meddon","Meddon"),
  209.                 "Dancing+Script"               => array("Dancing Script","Dancing Script"),
  210.                 "Just+Me+Again+Down+Here"      => array("Just Me Again Down Here","Just Me Again Down Here"),
  211.                 "Amaranth"                     => array("Amaranth","Amaranth"),
  212.                 "Anonymous+Pro"                => array("Anonymous Pro","Anonymous Pro"),
  213.                 "Kreon"                        => array("Kreon","Kreon"),
  214.                 "Carter+One"                   => array("Carter One","Carter One")             
  215.                 );
  216.    
  217.     //Available Social Media Icons
  218.     public $social_media_icons=array(
  219.                 "RSS"         => "rss",
  220.                 "Email"       => "email_icon",
  221.                 "Twitter"     => "twitter",
  222.                 "Flickr"      => "flickr",
  223.                 "Facebook"    => "facebook",
  224.                 "AIM"         => "aim",
  225.                 "Apple"       => "apple",
  226.                 "Appstore"    => "appstore",
  227.                 "Bing"        => "bing",
  228.                 "Blogger"     => "blogger",
  229.                 "Bookmark"    => "bookmark",
  230.                 "Delicious"   => "delicious",
  231.                 "Deviantart"  => "deviantart",
  232.                 "Digg"        => "digg",
  233.                 "Dribble"     => "dribble",
  234.                 "Evernote"    => "evernote",
  235.                 "Feedburner"  => "feedburner",
  236.                 "Forrst"      => "forrst",
  237.                 "Friendfeed"  => "friendfeed",
  238.                 "Google Plus" => "googleplus",
  239.                 "Google"      => "google",
  240.                 "Google Buzz" => "googlebuzz",
  241.                 "GTalk"       => "gtalk",
  242.                 "Lastfm"      => "lastfm",
  243.                 "Linkedin"    => "linkedin",
  244.                 "Messenger"   => "messenger",
  245.                 "Myspace"     => "myspace",
  246.                 "Reddit"      => "reddit",
  247.                 "Skype"       => "skype",
  248.                 "Technorati"  => "technorati",
  249.                 "Vimeo"       => "vimeo",
  250.                 "Yahoo"       => "yahoo",
  251.                 "YouTube"     => "youtube",
  252.                 "Pinterest"   => "pinterest"
  253.                 );
  254.                
  255.  
  256.     function start($v){
  257.        
  258.         global $fonts,$google_fonts,$social_media_icons,$RTThemePageLayoutOptionsClass;
  259.         $fonts              = $this->fonts;
  260.         $google_fonts           = $this->google_fonts;
  261.         $social_media_icons     = $this->social_media_icons;
  262.  
  263.         // Load text domain
  264.         load_theme_textdomain('rt_theme', get_template_directory().'/languages' );
  265.  
  266.         //Call Theme Constants
  267.         $this->theme_constants($v);  
  268.  
  269.         //Load Classes
  270.         $this->load_classes($v);
  271.        
  272.         //Load Widgets
  273.         $this->load_widgets($v);       
  274.        
  275.         //Load Functions
  276.         $this->load_functions($v);
  277.  
  278.         //Create Menus
  279.         add_action('init', array(&$this,'rt_create_menus'));
  280.                
  281.         //Theme Supports
  282.         $this->theme_supports();
  283.        
  284.         //Admin Panel Jobs
  285.         if(is_admin()){    
  286.             require_once (THEMEFRAMEWORKDIR.'/classes/admin.php');
  287.             $RTadmin = new RTThemeAdmin();
  288.             $RTadmin -> admin_init();
  289.        
  290.            
  291.             //Save Default Options - First time loading or options resetted
  292.             $this_page_url='http://'.$_SERVER['HTTP_HOST'].''.$_SERVER['SCRIPT_NAME'];
  293.             $option_page_url=WPADMINURI.'admin.php';
  294.             if(get_option(THEMESLUG.'_'.UTHEMENAME.'_defaults')!='saved' || (@$_GET['reset_settings']=='true') ){
  295.                
  296.                 //reset options
  297.                 $this->rt_save_defaults($RTadmin);
  298.  
  299.                 //create default templates     
  300.                 $RTThemePageLayoutOptionsClass->rt_create_default_templates();
  301.  
  302.                 if($_GET['reset_settings']=='true') add_action('admin_notices', array(&$this,'reset_message'));        
  303.             }
  304.         }
  305.  
  306.         //check woocommerce
  307.         if ( class_exists( 'Woocommerce' ) ) {
  308.             include(THEMEFRAMEWORKDIR . "/functions/woo-integration.php");
  309.         }
  310.  
  311.         //Ajax Contact Form
  312.         add_action('wp_ajax_rt_ajax_contact_form', array(&$this,'rt_ajax_contact_form'));
  313.         add_action('wp_ajax_nopriv_rt_ajax_contact_form', array(&$this,'rt_ajax_contact_form'));
  314.  
  315.         //Ajax Product Scroller
  316.         add_action('wp_ajax_rt_ajax_product_scroller', array(&$this,'rt_ajax_product_scroller'));
  317.         add_action('wp_ajax_nopriv_rt_ajax_product_scroller', array(&$this,'rt_ajax_product_scroller'));
  318.          
  319.     }
  320.    
  321.     #
  322.     # Paging fix for custom post archives
  323.     #
  324.    
  325.     function fix_content( $content )
  326.     {
  327.         $content = str_replace('<p><br class="clear" /></p>', "<div class='clear'></div>", trim($content));
  328.         $content = str_replace('<p></p>', "", trim($content));
  329.         return $content;
  330.     }
  331.  
  332.     #
  333.     # Ajax product scroller
  334.     #
  335.    
  336.     function rt_ajax_product_scroller()
  337.     {
  338.         global $args,$cotent_generator,$this_column_width_pixel,$content_width,$item_width,$layout;
  339.  
  340.             //page
  341.             $list_orderby ="date";
  342.             $list_order ="ascending";
  343.             $item_per_page =3;
  344.             $paged = 1;
  345.             $categories = "";
  346.  
  347.             if(isset($_POST['paged'])) $paged = trim($_POST['paged']);
  348.             if(isset($_POST['order'])) $list_order = trim($_POST['order']);
  349.             if(isset($_POST['orderby'])) $list_orderby = trim($_POST['orderby']);
  350.             if(isset($_POST['posts_per_page'])) $item_per_page = trim($_POST['posts_per_page']);
  351.             if(isset($_POST['categories'])){
  352.                 if(strpos($_POST['categories'],",")){
  353.                     $categories = @explode(",", trim($_POST['categories']));
  354.                 }else{
  355.                     $categories = @trim($_POST['categories']);
  356.                 }
  357.             }
  358.  
  359.             if(isset($_POST['layout']))  $layout = trim($_POST['layout']);
  360.             if(isset($_POST['item_width']))  $item_width = trim($_POST['item_width']);
  361.             if(isset($_POST['content_width']))  $content_width = trim($_POST['content_width']);
  362.             if(isset($_POST['this_column_width_pixel']))  $this_column_width_pixel = trim($_POST['this_column_width_pixel']);
  363.             if(isset($_POST['cotent_generator']))  $cotent_generator = trim($_POST['cotent_generator']);
  364.  
  365.             //general query
  366.             $args=array(
  367.                 'post_status'    => 'publish',
  368.                 'post_type'      => 'products',
  369.                 'orderby'        => $list_orderby,
  370.                 'order'          => $list_order,
  371.                 'posts_per_page' => $item_per_page,
  372.                 'paged'          => $paged,
  373.  
  374.                 'tax_query' => array(
  375.                     array(
  376.                         'taxonomy' =>   'product_categories',
  377.                         'field'    =>   'id',
  378.                         'terms'    =>    ($categories) ? $categories : '',
  379.                         'operator' =>    ($categories) ? "IN" : "OR"
  380.                     )
  381.                 ),
  382.             );
  383.  
  384.             get_template_part( 'product_loop', 'product_categories' );
  385.  
  386.         die();
  387.     }
  388.  
  389.     #
  390.     # Ajax contact form
  391.     #
  392.    
  393.     function rt_ajax_contact_form()
  394.     {
  395.  
  396.         $your_web_site_name=trim(get_bloginfo('name'));
  397.         $your_email = rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5($your_web_site_name), base64_decode(trim($_POST['your_email'])), MCRYPT_MODE_CBC, md5(md5($your_web_site_name))), "\0");
  398.        
  399.         //texts
  400.         $text_1 = __('Thanks','rt_theme');
  401.         $text_2 = __('Your email was successfully sent. We will be in touch soon.','rt_theme');
  402.         $text_3 = __('There was an error submitting the form.','rt_theme');
  403.         $text_4 = __('Please enter a valid email address!','rt_theme');
  404.         $text_5 = __('Are you human? quiz error: Please make sure that the sum of the two numbers is correct!','rt_theme');
  405.  
  406.         //If the form is submitted
  407.         if(isset($_POST['name'])) {
  408.  
  409.             //Check the sum of the numbers
  410.             if(isset($_SESSION['are_you_human_sum'])){
  411.                 if(trim($_POST['math']) != '' &&  ($_SESSION['are_you_human_sum'] !=  trim($_POST['math']))) {                 
  412.                     $hasError = true;
  413.                     $errorMessage = $text_5;
  414.                 }
  415.             }else{
  416.                     $hasError = true;
  417.                     $errorMessage = $text_5;
  418.             }
  419.  
  420.             //Check to make sure that the name field is not empty
  421.             if(trim($_POST['name']) === '') {
  422.                 $hasError = true;
  423.             } else {
  424.                 $name = trim($_POST['name']);
  425.             }
  426.            
  427.             //Check to make sure sure that a valid email address is submitted
  428.             if(trim($_POST['email']) === '')  {
  429.                 $hasError = true;
  430.             } else if (!preg_match('^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+.[a-zA-Z0-9-.]+$^', trim($_POST['email']))) {
  431.                 $hasError = true;
  432.                 $errorMessage = $text_4;
  433.             } else {
  434.                 $email = trim($_POST['email']);
  435.             }
  436.    
  437.             //phone
  438.             if(isset($_POST['phone'])) $phone = trim($_POST['phone']);
  439.            
  440.             //company name
  441.             if(isset($_POST['company_name'])) $company_name = trim($_POST['company_name']);
  442.    
  443.             //company url
  444.             if(isset($_POST['company_url'])) $company_url = trim($_POST['company_url']);       
  445.                
  446.             //Check to make sure comments were entered 
  447.             if(trim($_POST['message']) === '') {
  448.                 $hasError = true;
  449.             } else {
  450.                 if(function_exists('stripslashes')) {
  451.                     $comments = stripslashes(trim($_POST['message']));
  452.                 } else {
  453.                     $comments = trim($_POST['message']);
  454.                 }
  455.             }
  456.    
  457.             //If there is no error, send the email
  458.             if(!isset($hasError)) {
  459.    
  460.                 $emailTo = $your_email;
  461.  
  462.                 $subject = __('Contact Form Submission from' , 'rt_theme').' '.$name;
  463.                
  464.                 //message body
  465.                 $body  = __('Name' , 'rt_theme').": $name \n\n";
  466.                 $body .= __('Email' , 'rt_theme').": $email \n\n";
  467.                 if(isset($phone)) $body .= __('Phone' , 'rt_theme').": $phone \n\n";
  468.                 if(isset($company_name)) $body .= __('Company Name' , 'rt_theme').": $company_name \n\n";
  469.                 if(isset($company_url)) $body .= __('Company Url' , 'rt_theme').": $company_url \n\n";
  470.                 $body .= __('Message' , 'rt_theme').": $comments \n\n";
  471.    
  472.                 $headers = 'From: '.$name.' <'.$email.'>' . "\r\n" . 'Reply-To: ' . $email;
  473.                
  474.                 wp_mail($emailTo, $subject, $body, $headers);
  475.                 $emailSent = true;
  476.             }
  477.  
  478.             //dynamic form class
  479.             if(isset($_POST['dynamic_class'])) $dynamic_class = trim($_POST['dynamic_class']);         
  480.         }
  481.        
  482.         if(isset($emailSent) == true) {
  483.         echo '
  484.             <div class="ok_box">
  485.                 <h3>'.$text_1.', '.$name.'</h3>
  486.                 <p>'.$text_2.'</p>
  487.                 <script>
  488.                     jQuery(document).ready(function(){
  489.                         jQuery(".'.$dynamic_class.'").find("input,textarea").attr("disabled", "disabled");
  490.                         jQuery(".'.$dynamic_class.'").find(".button").remove();
  491.                     });
  492.                 </script>
  493.             </div>
  494.         ';
  495.         //reset sum
  496.         unset($_SESSION['are_you_human']);
  497.         }
  498.        
  499.         if(isset($hasError) ) {
  500.         echo '
  501.             <div class="error_box">
  502.                 '.$text_3.'
  503.                 <br />
  504.                 '.@$errorMessage.'
  505.             </div>
  506.         ';
  507.         }
  508.  
  509.         die();
  510.     }
  511.  
  512.     #
  513.     # Frontend Ajax URL
  514.     #
  515.  
  516.     function frontend_ajaxurl() {
  517.         $admin_ajax_url = admin_url('admin-ajax.php');
  518.         echo '<script type="text/javascript">';
  519.         echo 'var ajaxurl = "'.$admin_ajax_url.'"; ';
  520.         echo '</script>';
  521.     }
  522.  
  523.  
  524.     #
  525.     #   Messages
  526.     #
  527.    
  528.     function reset_message(){
  529.         echo '<div id="notice" class="error"><p>'.__('theme options has been resetted.', 'rt_theme_admin').'</p></div>';
  530.     }  
  531.    
  532.    
  533.     #
  534.     #   Theme Constants
  535.     #
  536.    
  537.     function theme_constants($v) {
  538.         define('THEMENAME', $v['theme']);
  539.         define('THEMESLUG', $v['slug']);
  540.         define('THEMEVERSION', $v['version']);
  541.         define('THEMEDIR', get_template_directory());
  542.         define('THEMEURI', get_template_directory_uri());
  543.    
  544.         if(function_exists('icl_get_home_url')){
  545.            define('BLOGURL', icl_get_home_url());
  546.         }else{
  547.             define('BLOGURL', home_url() );  
  548.         }
  549.    
  550.         define('FRAMEWORKSLUG', 'rt-framework');
  551.         define('THEMEFRAMEWORKDIR', get_template_directory().'/rt-framework');
  552.         define('THEMEADMINDIR', get_template_directory().'/rt-framework/admin');
  553.         define('THEMEADMINURI', get_template_directory_uri().'/rt-framework/admin');
  554.         define('WPADMINURI', get_admin_url());
  555.         define('BLOGPAGE', get_option('rttheme_blog_page'));
  556.         define('PRODUCTPAGE', get_option('rttheme_product_list'));
  557.         define('PORTFOLIOPAGE', get_option('rttheme_portf_page'));
  558.         define('CONTACTPAGE', get_option('rttheme_contact_page'));
  559.         define('THEMESTYLE', get_option(THEMESLUG."_style"));
  560.  
  561.         // Constants for notifier
  562.         define( 'NOTIFIER_THEME_FOLDER_NAME', 'rttheme17' );  
  563.         define( 'NOTIFIER_XML_FILE', 'http://templatemints.com/theme_updates/rttheme17/notifier.xml' );
  564.         define( 'NOTIFIER_CACHE_INTERVAL', 21600 );
  565.        
  566.         //unique theme name for default settings
  567.         define('UTHEMENAME', "RTTHEME17");
  568.            
  569.     }    
  570.    
  571.     #
  572.     #   Load Functions
  573.     #
  574.    
  575.     function load_functions($v) {
  576.         include(THEMEFRAMEWORKDIR . "/functions/common_functions.php");    
  577.         include(THEMEFRAMEWORKDIR . "/functions/rt_comments.php");
  578.         include(THEMEFRAMEWORKDIR . "/functions/custom_posts.php");
  579.         include(THEMEFRAMEWORKDIR . "/functions/theme_functions.php");
  580.         include(THEMEFRAMEWORKDIR . "/functions/rt_breadcrumb.php");
  581.         include(THEMEFRAMEWORKDIR . "/functions/rt_shortcodes.php");       
  582.         include(THEMEFRAMEWORKDIR . "/functions/wpml_functions.php");
  583.         include(THEMEFRAMEWORKDIR . "/functions/custom_styling.php");
  584.         include(THEMEFRAMEWORKDIR . "/plugins/vt_resize.php");     
  585.        
  586.         if(!function_exists('dropdown_menu')){     
  587.             include(THEMEFRAMEWORKDIR . "/plugins/dropdown-menus.php");
  588.         }
  589.     }
  590.  
  591.     #
  592.     #   Load Classes
  593.     #
  594.    
  595.     function load_classes($v) {
  596.        
  597.         //Create Sidebars
  598.         include(THEMEFRAMEWORKDIR . "/classes/sidebar_creator.php");  
  599.         $createSidebars = new RT_Create_Sidebars();
  600.        
  601.         //is login or register page    
  602.         $is_login = in_array( $GLOBALS['pagenow'], array( 'wp-login.php', 'wp-register.php' ));
  603.  
  604.         //Theme
  605.         if(!is_admin() && !$is_login){
  606.             require_once (THEMEFRAMEWORKDIR.'/classes/theme.php');
  607.             $RTThemeSite = new RTThemeSite();
  608.             $RTThemeSite -> theme_init();
  609.  
  610.             //Navigation Walker
  611.             include(THEMEFRAMEWORKDIR . "/classes/navigation_walker.php");     
  612.         }
  613.  
  614.         //Common Classes
  615.         include(THEMEFRAMEWORKDIR . "/classes/common_classes.php");  
  616.        
  617.     }        
  618.  
  619.     #
  620.     #   Load Widgets
  621.     #
  622.    
  623.     function load_widgets($v) {
  624.        
  625.         if ( ! class_exists( 'Twitter_Widget' ) ) {
  626.             //twitter
  627.             include(THEMEFRAMEWORKDIR . "/widgets/twitter.php");       
  628.             register_widget('Twitter_Widget');
  629.         }
  630.  
  631.         if ( ! class_exists( 'Flickr_Widget' ) ) {
  632.             //flickr
  633.             include(THEMEFRAMEWORKDIR . "/widgets/flickr.php");    
  634.             register_widget('Flickr_Widget');
  635.         }
  636.  
  637.         if ( ! class_exists( 'Latest_Posts' ) ) {
  638.             //recent posts with thumbnails
  639.             include(THEMEFRAMEWORKDIR . "/widgets/latest_posts.php");      
  640.             register_widget('Latest_Posts');
  641.         }
  642.  
  643.         if ( ! class_exists( 'Popular_Posts' ) ) {
  644.             //popular posts
  645.             include(THEMEFRAMEWORKDIR . "/widgets/popular_posts.php");     
  646.             register_widget('Popular_Posts');
  647.         }
  648.  
  649.         if ( ! class_exists( 'Contact_Info' ) ) {          
  650.             //contact info
  651.             include(THEMEFRAMEWORKDIR . "/widgets/contact_info.php");      
  652.             register_widget('Contact_Info');
  653.         }
  654.  
  655.         if ( ! class_exists( 'Testimonials' ) ) {  
  656.             //testimonials
  657.             include(THEMEFRAMEWORKDIR . "/widgets/testimonials.php");      
  658.             register_widget('Testimonials');
  659.         }
  660.  
  661.         if ( ! class_exists( 'RT_Products' ) ) {   
  662.             //testimonials
  663.             include(THEMEFRAMEWORKDIR . "/widgets/products.php");      
  664.             register_widget('RT_Products');
  665.         }
  666.  
  667.     }
  668.    
  669.    
  670.     #
  671.     #   Save Default Values
  672.     #
  673.    
  674.     function rt_save_defaults($RTadmin) {
  675.    
  676.         if(is_array($RTadmin->panel_pages)){
  677.             foreach($RTadmin->panel_pages  as $menu_slug => $page_title){
  678.                
  679.                 if($menu_slug!="rt_sidebar_options" && $menu_slug!="rt_template_options" && $menu_slug!="rt_setup_assistant" ){        
  680.                     include(THEMEADMINDIR . "/options/$menu_slug.php");
  681.        
  682.                     if(is_array($options)){
  683.                         foreach($options as $k => $v){
  684.                             if(@$v['default'] && @!$v['dont_save']) {
  685.                                 update_option( @$v['id'], stripslashes(@$v['default']));
  686.                             }else{
  687.                                 update_option( @$v['id'], '' );
  688.                             }
  689.                         }
  690.                     }
  691.                    
  692.                     update_option(THEMESLUG.'_'.UTHEMENAME.'_defaults','saved');
  693.                 }
  694.             }
  695.         }
  696.     }
  697.    
  698.     #
  699.     #   Create WP Menus
  700.     #
  701.  
  702.     function rt_create_menus() {
  703.        
  704.         register_nav_menu( 'rt-theme-main-navigation', __( 'RT Theme Main Navigation' , 'rt_theme_admin') );
  705.         register_nav_menu( 'rt-theme-footer-navigation', __( 'RT Theme Footer Navigation' , 'rt_theme_admin' ));
  706.        
  707.         wp_create_nav_menu( 'RT Theme Main Navigation Menu', array( 'slug' => 'rt-theme-main-navigation' ) );
  708.         wp_create_nav_menu( 'RT Theme Footer Navigation Menu', array( 'slug' => 'rt-theme-footer-navigation') );
  709.    
  710.     }
  711.  
  712.     #
  713.     #   Theme Supports
  714.     #
  715.      
  716.     function theme_supports(){
  717.         //Featured Images
  718.         add_theme_support( 'post-thumbnails', array('slider','home_page','page','product') );
  719.          
  720.         //Automatic Feed Links
  721.         add_theme_support( 'automatic-feed-links' );
  722.        
  723.         //Supported Post Formats
  724.         add_theme_support( 'post-formats', array( 'gallery' , 'link', 'video', 'audio', 'aside') );
  725.     }  
  726.  
  727.  
  728.     #
  729.     #   Get Pages as array
  730.     #
  731.  
  732.     public static function rt_get_pages(){
  733.          
  734.         // Pages       
  735.         $pages = query_posts('posts_per_page=-1&post_type=page&orderby=title&order=ASC');
  736.         $rt_getpages = array();
  737.        
  738.         if(is_array($pages)){
  739.             foreach ($pages as $page_list ) {
  740.                 $rt_getpages[$page_list->ID] = $page_list ->post_title;
  741.             }
  742.         }
  743.        
  744.         wp_reset_query();
  745.         return $rt_getpages;
  746.        
  747.     }
  748.  
  749.  
  750.     #
  751.     #   Get Blog Categories - only post categories
  752.     #
  753.  
  754.     public static function rt_get_categories(){
  755.  
  756.         // Categories
  757.         $args = array(
  758.             'type'                     => 'post',
  759.             'child_of'                 => 0,
  760.             'orderby'                  => 'name',
  761.             'order'                    => 'ASC',
  762.             'hide_empty'               => 1,
  763.             'hierarchical'             => 1,  
  764.             'taxonomy'                 => 'category',
  765.             'pad_counts'               => false
  766.             );
  767.        
  768.        
  769.         $categories = get_categories($args);
  770.         $rt_getcat = array();
  771.        
  772.         if(is_array($categories)){
  773.             foreach ($categories as $category_list ) {
  774.                 $rt_getcat[$category_list->cat_ID] = $category_list->cat_name;
  775.             }
  776.         }
  777.    
  778.         return $rt_getcat;
  779.     }
  780.  
  781.  
  782.     #
  783.     #   Get Woo Product Categories
  784.     #
  785.  
  786.     public static function rt_get_woo_product_categories(){
  787.  
  788.         // Product Categories      
  789.         $product_args = array(
  790.             'type'                     => 'post',
  791.             'child_of'                 => 0,
  792.             'orderby'                  => 'name',
  793.             'order'                    => 'ASC',
  794.             'hide_empty'               => 1,
  795.             'hierarchical'             => 1,  
  796.             'taxonomy'                 => 'product_cat',
  797.             'pad_counts'               => false
  798.             );
  799.        
  800.        
  801.         $product_categories = get_categories($product_args);
  802.         $rt_product_getcat = array();
  803.        
  804.         if(is_array($product_categories)){
  805.             foreach ($product_categories as $category_list ) {
  806.                 @$rt_product_getcat[$category_list->slug] = @$category_list->cat_name;
  807.             }
  808.         }
  809.        
  810.         return $rt_product_getcat;
  811.        
  812.     }
  813.  
  814.  
  815.     #
  816.     #   Get Product Categories - only product categories with slugs
  817.     #
  818.  
  819.     public static function rt_get_product_categories_with_slugs(){
  820.  
  821.         // Product Categories      
  822.         $product_args = array(
  823.             'type'                     => 'post',
  824.             'child_of'                 => 0,
  825.             'orderby'                  => 'name',
  826.             'order'                    => 'ASC',
  827.             'hide_empty'               => 1,
  828.             'hierarchical'             => 1,  
  829.             'taxonomy'                 => 'product_categories',
  830.             'pad_counts'               => false
  831.             );
  832.        
  833.        
  834.         $product_categories = get_categories($product_args);
  835.         $rt_product_getcat = array();
  836.        
  837.         if(is_array($product_categories)){
  838.             foreach ($product_categories as $category_list ) {
  839.                 @$rt_product_getcat[$category_list->slug] = @$category_list->cat_name;
  840.             }
  841.         }
  842.        
  843.         return $rt_product_getcat;
  844.        
  845.     }
  846.  
  847.  
  848.     #
  849.     #   Get Product Categories - only product categories with cat IDs
  850.     #
  851.  
  852.     public static function rt_get_product_categories(){
  853.  
  854.         // Product Categories      
  855.         $product_args = array(
  856.             'type'                     => 'post',
  857.             'child_of'                 => 0,
  858.             'orderby'                  => 'name',
  859.             'order'                    => 'ASC',
  860.             'hide_empty'               => 1,
  861.             'hierarchical'             => 1,  
  862.             'taxonomy'                 => 'product_categories',
  863.             'pad_counts'               => false
  864.             );
  865.        
  866.        
  867.         $product_categories = get_categories($product_args);
  868.         $rt_product_getcat = array();
  869.        
  870.         if(is_array($product_categories)){
  871.             foreach ($product_categories as $category_list ) {
  872.                 @$rt_product_getcat[$category_list->cat_ID] = @$category_list->cat_name;
  873.             }
  874.         }
  875.        
  876.         return $rt_product_getcat;
  877.        
  878.     }
  879.  
  880.     #
  881.     #   Get Portfolio Categories
  882.     #
  883.  
  884.     public static function rt_get_portfolio_categories(){
  885.  
  886.         // Product Categories      
  887.         $product_args = array(
  888.             'type'                     => 'post',
  889.             'child_of'                 => 0,
  890.             'orderby'                  => 'name',
  891.             'order'                    => 'ASC',
  892.             'hide_empty'               => 1,
  893.             'hierarchical'             => 1,  
  894.             'taxonomy'                 => 'portfolio_categories',
  895.             'pad_counts'               => false
  896.             );
  897.        
  898.        
  899.         $portfolio_categories = get_categories($product_args);
  900.         $rt_portfolio_getcat = array();
  901.        
  902.         if(is_array($portfolio_categories)){
  903.             foreach ($portfolio_categories as $category_list ) {
  904.                 @$rt_portfolio_getcat[$category_list->cat_ID] = @$category_list->cat_name;
  905.             }
  906.         }
  907.        
  908.         return $rt_portfolio_getcat;
  909.        
  910.     }
  911.  
  912.  
  913.     #
  914.     #   Get Products
  915.     #
  916.  
  917.     public static function rt_get_products(){
  918.  
  919.        
  920.         $products  = query_posts('posts_per_page=-1&post_type=products&orderby=title&order=ASC'); // Products
  921.         $rt_get_product= array();
  922.  
  923.         if(is_array($products)){
  924.             foreach ($products as $post_list ) {    // add product posts to the list
  925.                 $rt_get_product[$post_list->ID] = $post_list ->post_title;
  926.             }
  927.         }
  928.        
  929.         wp_reset_query();
  930.         return $rt_get_product;
  931.        
  932.     }
  933.    
  934.     #
  935.     #   Get Home Contents
  936.     #
  937.  
  938.     public static function rt_get_homecontents(){
  939.  
  940.             $home_page=array(
  941.                 'post_type'=> 'home_page',
  942.                 'post_status'=> 'publish',
  943.                 'ignore_sticky_posts'=>1,
  944.                 'showposts' => 1000,
  945.                 'orderby'=> 'date',
  946.                 'order' => 'ASC',
  947.                 'cat' => -0,
  948.             );
  949.        
  950.        
  951.        
  952.         $home_contents  = query_posts($home_page);
  953.        
  954.        
  955.        
  956.        
  957.         $rt_get_homepage_posts= array();
  958.        
  959.         if(is_array($rt_get_homepage_posts)){
  960.             foreach ($home_contents as $spost_list ) {  // add product posts to the list
  961.                 $rt_get_homepage_posts[$spost_list->ID] = $spost_list ->post_title;
  962.             }
  963.         }
  964.  
  965.         wp_reset_query();
  966.         return $rt_get_homepage_posts;
  967.        
  968.     }
  969.  
  970.     #
  971.     #   Get Slider Contents
  972.     #
  973.  
  974.     public static function rt_get_slidercontents(){
  975.  
  976.             $slider_arg=array(
  977.                 'post_type'=> 'slider',
  978.                 'post_status'=> 'publish',
  979.                 'ignore_sticky_posts'=>1,
  980.                 'showposts' => 1000,
  981.                 'orderby'=> 'date',
  982.                 'order' => 'ASC',
  983.                 'cat' => -0,
  984.             );
  985.        
  986.        
  987.         $slider_contents  = query_posts($slider_arg);
  988.        
  989.        
  990.        
  991.         $rt_get_slidercontents= array();
  992.        
  993.         if(is_array($rt_get_slidercontents)){
  994.             foreach ($slider_contents as $spost_list ) {    // add product posts to the list
  995.                 $rt_get_slidercontents[$spost_list->ID] = $spost_list ->post_title;
  996.             }
  997.         }
  998.  
  999.         wp_reset_query();
  1000.         return $rt_get_slidercontents;
  1001.        
  1002.     }
  1003.  
  1004.  
  1005.  
  1006. }
  1007.  
  1008.  
  1009. ?>
Add Comment
Please, Sign In to add comment