Don't like ads? PRO users don't see any ads ;-)
Guest

Creatavix Functions With Basic Google Placemarks

By: andy3000 on Aug 11th, 2012  |  syntax: None  |  size: 83.84 KB  |  hits: 42  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2.  
  3. function bgmpShortcodeCalled()
  4. {
  5.         global $post;
  6.  
  7.         $shortcodePageSlugs = array(
  8.                 'home'
  9.         );
  10.  
  11.         if( $post )
  12.                 if( in_array( $post->post_name, $shortcodePageSlugs ) )
  13.                         add_filter( 'bgmp_map-shortcode-called', '__return_true' );
  14. }
  15. add_action( 'wp', 'bgmpShortcodeCalled' );
  16.  
  17.  
  18. $wpcx_cxOptions = get_option('cxOptions');
  19.  
  20. // Set Content Width
  21.  
  22. $content_width = 600;
  23.  
  24. //Load Styles
  25.  
  26. add_action('wp_print_styles', 'wpcx_add_my_stylesheet');
  27.  
  28. function wpcx_add_my_stylesheet() {
  29.        
  30.         if ( !is_admin() ) {
  31.                 global $wpcx_cxOptions;
  32.                
  33.                 if(!empty($wpcx_cxOptions['colorpicker'])) {
  34.                         $wpcx_colour = $wpcx_cxOptions['colorpicker'];
  35.                 } else {
  36.                         $wpcx_colour = false;
  37.                 }
  38.                
  39.                 $wpcx_main_style = get_template_directory_uri() . '/style.css';
  40.                 wp_register_style('mainStyle', $wpcx_main_style);
  41.                 wp_enqueue_style('mainStyle');
  42.                
  43.                 if($wpcx_colour) {
  44.                         $wpcx_sub_style = get_template_directory_uri() . '/style.php?color=' . $wpcx_colour;
  45.                 } else {
  46.                         $wpcx_sub_style = get_template_directory_uri() . '/style.php';
  47.                 }
  48.                 wp_register_style('wpcx_sub_style', $wpcx_sub_style);
  49.                 wp_enqueue_style('wpcx_sub_style');
  50.         }
  51.        
  52. }
  53.  
  54. add_action('admin_init', 'wpcx_add_to_admin_style');
  55.  
  56. function wpcx_add_to_admin_style() {
  57.        
  58.         $wpcx_admin_style = get_template_directory_uri() . '/admin.css';
  59.         wp_register_style('wpcx_admin_style', $wpcx_admin_style);
  60.         wp_enqueue_style('wpcx_admin_style');
  61.        
  62. }
  63.  
  64. function wpcx_add_margin_header() {
  65.        
  66.         global $wpcx_cxOptions;
  67.                
  68.         if(!empty($wpcx_cxOptions["logo_margin"])) {
  69.  
  70.                 echo "<style type='text/css'>#header { margin-top: " . $wpcx_cxOptions["logo_margin"] . "px;}</style>";
  71.  
  72.         }
  73.        
  74. }
  75.  
  76. add_action('wp_head', 'wpcx_add_margin_header');
  77.  
  78. //Load JS
  79.  
  80. add_action('init', 'wpcx_add_my_scripts');
  81.  
  82. function wpcx_add_my_scripts() {
  83.        
  84.         if ( !is_admin() ) {
  85.            
  86.                 wp_register_script('wpcx_jquery.cycle', get_template_directory_uri() . '/scripts/jquery.cycle.all.js', array('jquery'), '1.0' );
  87.                 wp_enqueue_script('wpcx_jquery.cycle');
  88.                 wp_register_script('wpcx_jquery.superfish', get_template_directory_uri() . '/scripts/jquery.superfish.js', array('jquery'), '1.0' );
  89.                 wp_enqueue_script('wpcx_jquery.superfish');
  90.                 wp_register_script('wpcx_jquery.fredsel', get_template_directory_uri() . '/scripts/jquery.carouFredSel-2.3.1.js', array('jquery'), '1.0' );
  91.                 wp_enqueue_script('wpcx_jquery.fredsel');
  92.                 wp_register_script('wpcx_jquery.fancybox', get_template_directory_uri() . '/scripts/jquery.fancybox-1.3.4.pack.js', array('jquery'), '1.0' );
  93.                 wp_enqueue_script('wpcx_jquery.fancybox');
  94.                 wp_register_script('wpcx_custom', get_template_directory_uri() . '/scripts/custom.js', array('jquery'), '1.0' );
  95.                 wp_enqueue_script('wpcx_custom');
  96.            
  97.         } else {
  98.            
  99.                 wp_register_script('wpcx_jquery.picker', get_template_directory_uri() . '/scripts/jquery.picker.js', array('jquery'), '1.0' );
  100.                 wp_enqueue_script('wpcx_jquery.picker');
  101.                 wp_register_script('wpcx_admin_custom', get_template_directory_uri() . '/scripts/admin_custom.js', array('jquery'), '1.0' );
  102.                 wp_enqueue_script('wpcx_admin_custom');
  103.            
  104.         }
  105. }
  106.  
  107. // Custom Logo Support
  108.  
  109. define( 'HEADER_IMAGE', '%s/images/logo.png' );
  110.  
  111. define( 'HEADER_IMAGE_WIDTH', apply_filters( '', 520 ) );
  112.  
  113. define( 'HEADER_IMAGE_HEIGHT', apply_filters( '', 155 ) );
  114.  
  115. define( 'HEADER_TEXTCOLOR', '' );
  116.  
  117. define( 'NO_HEADER_TEXT', true );
  118.  
  119. add_custom_image_header( '', 'wpcx_admin_header_style' );
  120.  
  121. //Add custom post type "Portfolio"
  122.  
  123. function wpcx_post_type_myportfolio() {
  124.        
  125. register_post_type(
  126.         'myportfolio',
  127.         array('label' => 'Portfolio',
  128.                 'singular_label' => 'Portfolio',
  129.                 'public' => true,
  130.                 'show_ui' => true,
  131.                 'capability_type' => 'post',
  132.                 'hierarchical' => false,
  133.                 'rewrite' => array("slug" => "portfolio-item", "with_front" => false),
  134.                 'supports' => array('title','editor','custom-fields','revisions','thumbnail'),
  135.                 'menu_position' => 4
  136.         )
  137. );
  138.         register_taxonomy( 'portfolio', 'myportfolio', array( 'hierarchical' => true, 'label' => 'Portfolio Categories' ) );
  139.        
  140. }
  141.  
  142. add_action('init','wpcx_post_type_myportfolio');
  143.  
  144. if (!function_exists( 'wpcx_admin_header_style' )) {
  145.        
  146.         function wpcx_admin_header_style() { ?>
  147.  
  148.                 <style type="text/css">
  149.                
  150.                 #headimg {
  151.                         height: <?php echo HEADER_IMAGE_HEIGHT; ?>px;
  152.                         width: <?php echo HEADER_IMAGE_WIDTH; ?>px;
  153.                 }
  154.                
  155.                 #headimg h1, #headimg #desc {
  156.                         display: none;
  157.                 }
  158.                
  159.                 </style>
  160.         <?php }
  161. }
  162.  
  163. //WP 3.0 Menu
  164.  
  165. add_action('init', 'wpcx_register_custom_menu');
  166.  
  167. function wpcx_register_custom_menu() {
  168.         register_nav_menu('footer_menu', 'Footer Menu');
  169.         register_nav_menu('nav_menu', 'Navigation Menu');
  170. }
  171.  
  172. //Remove wp_nav wrapping
  173.  
  174. function wpcx_my_nav_unlister( $menu ){
  175.         return preg_replace( array( '#^<ul[^>]*>#', '#</ul>$#' ), '', $menu );
  176. }
  177.  
  178. add_filter( 'wp_nav_menu', 'wpcx_my_nav_unlister' );
  179.  
  180. // Fallback Nav Menus
  181.  
  182. function wpcx_default_menu() {
  183.        
  184.         echo "<li><a href='" . home_url() . "/'>Home</a></li>";
  185.  
  186. }
  187.  
  188. // Cut some text
  189.  
  190. function wpcx_cut_text($text, $chars, $points = "...") {
  191.         $length = strlen($text);
  192.         if($length <= $chars) {
  193.                 return $text;
  194.         } else {
  195.                 return substr($text, 0, $chars)." ".$points;
  196.         }
  197. }
  198.  
  199. // Get WP Generated thumb
  200.  
  201. function wpcx_get_wp_generated_thumb($position) {
  202.         global $post_id;
  203.         $thumb = get_the_post_thumbnail($post_id, $position);
  204.         $thumb = explode("\"", $thumb);
  205.         if(!empty($thumb[5])) {
  206.                 return $thumb[5];
  207.         }
  208. }
  209.  
  210. if (function_exists('add_image_size')) {
  211.         add_image_size( 'slideshow', 480, 210, true );
  212.         add_image_size( 'slideshow_thumb', 100, 75, true );
  213.         add_image_size( 'reference', 250, 130, true );
  214.         add_image_size( 'feat_thumb', 295, 150, true );
  215. }
  216.  
  217. // Styling & Script Functions
  218.  
  219. function wpcx_script() {
  220.        
  221.         global $wpcx_cxOptions;
  222.        
  223.         if(!empty($wpcx_cxOptions["slide_effect"])) {
  224.                
  225.                 $wpcx_slide_effect = $wpcx_cxOptions["slide_effect"];
  226.                
  227.         } else {
  228.                
  229.                 $wpcx_slide_effect = "scrollRight";
  230.                
  231.         }
  232.        
  233.         if(!empty($wpcx_cxOptions["slide_speed"])) {
  234.                
  235.                 $wpcx_slide_speed = $wpcx_cxOptions["slide_speed"];
  236.                
  237.         } else {
  238.                
  239.                 $wpcx_slide_speed = 500;
  240.                
  241.         }
  242.        
  243.         if(!empty($wpcx_cxOptions["slide_duration"])) {
  244.                
  245.                 $wpcx_slide_duration = $wpcx_cxOptions["slide_duration"];
  246.                
  247.         } else {
  248.                
  249.                 $wpcx_slide_duration = 3000;
  250.                
  251.         }
  252.        
  253.        
  254.        
  255.         $wpcx_script = '<script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>
  256.         <script type="text/javascript">
  257.                         jQuery(document).ready(function($) {
  258.                                 jQuery("ul#slideshow").cycle({
  259.                                         fx:             "'.$wpcx_slide_effect.'",
  260.                                         speed:          '.$wpcx_slide_speed.',
  261.                                         timeout:        '.$wpcx_slide_duration.',
  262.                                         pager:          "ul#slide_navigation",
  263.                         pagerAnchorBuilder: function(idx, slide) {
  264.                             // return selector string for existing anchor
  265.                             return "#slide_navigation li:eq(" + idx + ") a";
  266.                         }
  267.                 });
  268.        
  269.         });
  270.  
  271.         </script>';
  272.        
  273.         echo $wpcx_script;
  274.        
  275. }
  276.  
  277. add_action('wp_head', 'wpcx_script');
  278.  
  279. function wpcx_style() {
  280.        
  281.         $wpcx_style = "";
  282.        
  283.         global $wpcx_cxOptions;
  284.        
  285.         if(!empty($wpcx_cxOptions["logo_size"])) {
  286.                
  287.                 $wpcx_logo_size = $wpcx_cxOptions["logo_size"];
  288.                
  289.                 $style = '<style type="text/css">
  290.                 #logoname a {
  291.                 font-size: '.$wpcx_logo_size.'px !important;
  292.                 }
  293.                 </style>
  294.                 ';
  295.                
  296.         }
  297.  
  298.         if(empty($wpcx_cxOptions["logo_file"])) {
  299.                
  300.                
  301.                 $wpcx_style .= '<style type="text/css">
  302.                 #logoname {
  303.                 margin-top: 12px;
  304.                 }
  305.                 </style>
  306.                 ';
  307.  
  308.         }
  309.        
  310.         if(!empty($wpcx_style)) {
  311.                
  312.                 echo $wpcx_style;
  313.        
  314.         }
  315.        
  316. }
  317.  
  318. add_action('wp_head', 'wpcx_style');
  319.  
  320. function wpcx_list_pages() {
  321.        
  322.         echo "<li><a href='".get_bloginfo('url')."'>Home</a>";
  323.         wp_list_pages('title_li=');
  324.        
  325. }
  326.  
  327. // Featured Options
  328.  
  329. add_action("admin_init", "wpcx_admin_init");
  330. add_action('save_post', 'wpcx_save_feat');
  331.  
  332. function wpcx_admin_init(){
  333.         add_meta_box("page_feat", "Creativix Options", "wpcx_feat_options", "page", "normal", "high");
  334.         add_meta_box("post_feat", "Creativix Options", "wpcx_feat_options", "post", "normal", "high");
  335. }
  336.  
  337. function wpcx_feat_options(){
  338.        
  339.         global $post;
  340.         $wpcx_custom = get_post_custom($post->ID);
  341.         if(!empty($wpcx_custom)) {
  342.                 if(!empty($wpcx_custom["feat_slideshow"][0])) {
  343.                         $wpcx_featured = $wpcx_custom["feat_slideshow"][0];
  344.                 }
  345.                 if(!empty($wpcx_custom["feat_front"][0])) {
  346.                         $wpcx_feat_front = $wpcx_custom["feat_front"][0];
  347.                 }
  348.         }
  349. ?>
  350.         <div class="inside">
  351.                 <table class="form-table">
  352.                         <tr>
  353.                                 <th><label for="featured">Feature in Slideshow?</label></th>
  354.                                 <td><input type="checkbox" name="featured" value="1" <?php if(isset($wpcx_featured) && $wpcx_featured == 1) { echo "checked='checked'";} ?></td>
  355.                         </tr>
  356.                         <tr>
  357.                                 <th><label for="featured">Feature on frontpage?</label></th>
  358.                                 <td><input type="checkbox" name="feat_front" value="1" <?php if(isset($wpcx_feat_front) && $wpcx_feat_front == 1) { echo "checked='checked'";} ?></td>
  359.                         </tr>
  360.                 </table>
  361.         </div>
  362. <?php
  363. }
  364.  
  365. function wpcx_save_feat(){
  366.        
  367.         global $post;
  368.        
  369.         if($post->post_type == "post" OR $post->post_type == "page") {
  370.        
  371.                 if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE )
  372.                 return $post_id;
  373.                
  374.                
  375.                 if(isset($_POST["featured"])) {
  376.                        
  377.                         update_post_meta($post->ID, "feat_slideshow", $_POST["featured"]);
  378.                        
  379.                 } else {
  380.                        
  381.                         delete_post_meta($post->ID, "feat_slideshow", '');
  382.                        
  383.                 }
  384.                
  385.                 if(isset($_POST["feat_front"])) {
  386.                        
  387.                         update_post_meta($post->ID, "feat_front", $_POST["feat_front"]);
  388.                        
  389.                 } else {
  390.                        
  391.                         delete_post_meta($post->ID, "feat_front", '');
  392.                        
  393.                 }
  394.        
  395.         }
  396.        
  397. }
  398.  
  399.  
  400. //Check for Post Thumbnail Support
  401.  
  402. if ( function_exists( 'add_theme_support' ) )
  403. add_theme_support( 'post-thumbnails' );
  404.  
  405. // Register Sidebar
  406.  
  407. if ( function_exists('register_sidebar') )
  408.     register_sidebar();
  409.  
  410. // Add RSS
  411.  
  412. add_theme_support('automatic-feed-links');
  413.  
  414. // Custom BG
  415.  
  416. add_custom_background();
  417.  
  418. // Editor Style
  419.  
  420. add_editor_style();
  421.  
  422. //Loading Theme Options Framework
  423.  
  424. $wpcx_themename = "WP-Creativix";
  425. $wpcx_shortname = "Creativix";
  426.  
  427. $wpcx_options = array (
  428.        
  429. array( "type" => "open",
  430. "title" => "Frontpage Settings"
  431. ),
  432.  
  433. array( "name" => "Activate Slideshow on Frontpage?",
  434.        "desc" => "Decide if you want to show the big Slideshow on Frontpage. By default the Slideshow will be shown.",
  435.        "id" => "slide_show",
  436.        "type" => "selectnormal",
  437.        "options" => array("yes", "no"),
  438.        "std" => "yes"),
  439.  
  440. array( "name" => "Limit Posts/Pages in Slideshow",
  441.        "desc" => "Set maximum amount of posts/pages to be shown in the slideshow. Leave empty if you don't want to limit them.",
  442.        "id" => "slide_max",
  443.        "type" => "text",
  444.        "std" => ""),
  445.  
  446. array( "name" => "Sort Posts/Pages in Slideshow",
  447.        "desc" => "Choose how you want to sort your posts/pages in the Slideshow. Default sort order is by date",
  448.        "id" => "slide_sort",
  449.        "type" => "selectnormal",
  450.        "options" => array("post_date", "rand", "title"),
  451.        "std" => "post_date"),
  452.  
  453. array( "name" => "Order Posts/Pages in Slideshow",
  454.        "desc" => "Choose how you want to order your posts/pages in the Slideshow. Default order is DESC",
  455.        "id" => "slide_order",
  456.        "type" => "selectnormal",
  457.        "options" => array("DESC", "ASC"),
  458.        "std" => "DESC"),
  459.  
  460. array( "name" => "Choose Sliding Effect",
  461.        "desc" => "Choose an effect that will be applied for the Slideshow. Defaul ist scrollRight.",
  462.        "id" => "slide_effect",
  463.        "type" => "selectnormal",
  464.        "options" => array("scrollRight", "fade", 'scrollUp', 'scrollDown', 'blindZ', 'fadeZoom'),
  465.        "std" => "scrollRight"),
  466.  
  467. array( "name" => "Slideshow Transition Speed",
  468.        "desc" => "Set the Speed for the slideshow's transition. Default ist set to 500 (ms)",
  469.        "id" => "slide_speed",
  470.        "type" => "text",
  471.        "std" => "500"),
  472.  
  473. array( "name" => "Slideshow Duration",
  474.        "desc" => "Set duration for each single Slide Item. Default is set to 3000 (ms)",
  475.        "id" => "slide_duration",
  476.        "type" => "text",
  477.        "std" => "3000"),
  478.  
  479. array( "name" => "Sort Posts/Pages for Featured Posts on Frontage",
  480.        "desc" => "Choose how you want to sort your posts/pages in the Featured Area on Frontage. Default sort order is by date",
  481.        "id" => "featured_sort",
  482.        "type" => "selectnormal",
  483.        "options" => array("post_date", "rand", "title"),
  484.        "std" => "post_date"),
  485.  
  486. array( "name" => "Order Posts/Pages for Featured Posts on Frontpage",
  487.        "desc" => "Choose how you want to order your posts/pages in the Featured Area. Default order is DESC",
  488.        "id" => "featured_order",
  489.        "type" => "selectnormal",
  490.        "options" => array("DESC", "ASC"),
  491.        "std" => "DESC"),
  492.  
  493. array( "name" => "Sort Posts for Latest Articles",
  494.        "desc" => "Choose how you want to sort your latest Articles displayed next to featured Articles. Default sort order is by date",
  495.        "id" => "articles_sort",
  496.        "type" => "selectnormal",
  497.        "options" => array("date", "rand", "title"),
  498.        "std" => "date"),
  499.  
  500. array( "name" => "Order Posts for Latest Articles",
  501.        "desc" => "Choose how you want to order your latest Articles displayed next to featured Articles. Default order is DESC",
  502.        "id" => "articles_order",
  503.        "type" => "selectnormal",
  504.        "options" => array("DESC", "ASC"),
  505.        "std" => "DESC"),
  506.  
  507. array("type" => "close"),
  508.  
  509. array( "type" => "open",
  510.         "title" => "Styling Settings"
  511.         ),
  512.  
  513. array( "name" => "Logo Font Size",
  514.        "desc" => "Choose a font size for the Logo. Default font size is set to 26px.",
  515.        "id" => "logo_size",
  516.        "type" => "text",
  517.        "std" => "26"),
  518.  
  519. array( "name" => "Logo Text",
  520.        "desc" => "Choose text for the logo. Leave this empty to use your Wordpress Blog Title instead.",
  521.        "id" => "logo_name",
  522.        "type" => "text",
  523.        "std" => ""),
  524.  
  525. array( "name" => "Logo/Nav Margin",
  526.        "desc" => "Choose how many space should be between Social Menu and Navigation/Logo in px.",
  527.        "id" => "logo_margin",
  528.        "type" => "text",
  529.        "std" => ""),
  530.  
  531. array( "name" => "Logo Upload",
  532.        "desc" => "Upload your own Logo. The Logo will not be cropped/resized. You must apply correct width/height before uploading. (Folder wp-creativix/images/logos/ must be writeable)",
  533.        "id" => "logo_file",
  534.        "type" => "upload",
  535.        "std" => ""),
  536.  
  537. array( "name" => "Choose an highlight Colour",
  538.        "desc" => "Click on the input field and choose a highlight colour with the help of the colour-picker.",
  539.        "id" => "colorpicker",
  540.        "type" => "text",
  541.        "std" => "939393"),
  542.  
  543. array("type" => "close"),
  544.  
  545. array( "type" => "open",
  546.         "title" => "Social Media Settings"
  547.         ),
  548.  
  549. array( "name" => "Facebook Profile URL",
  550.        "desc" => "If you want to show the icon, enter the URL (http://..) that points to your Facebook profile. (Leave empty to not show the icon)",
  551.        "id" => "social_facebook",
  552.        "type" => "text",
  553.        "std" => ""),
  554.  
  555. array( "name" => "Linkedin Profile ID",
  556.        "desc" => "Insert your Linkedin Profile ID to show the Linkedin Icon in the Header. (Leave empty to not show the icon)",
  557.        "id" => "social_linkedin",
  558.        "type" => "text",
  559.        "std" => ""),
  560.  
  561. array( "name" => "Twitter Username",
  562.        "desc" => "Insert your Twitter Username to show the Twitter Icon in the Header. (Leave empty to not show the icon)",
  563.        "id" => "social_twitter",
  564.        "type" => "text",
  565.        "std" => ""),
  566.  
  567. array( "name" => "Show RSS Icon in Header?",
  568.        "desc" => "Choose if you want to display the RSS Icon in the Header. Default is set to yes.",
  569.        "id" => "social_rss",
  570.        "type" => "selectnormal",
  571.        "options" => array("yes", "no"),
  572.        "std" => "yes"),
  573.  
  574. array( "name" => "Let Users like posts on Facebook",
  575.        "desc" => "Choose if you want to display the facebook-like-button next to your Post. Default is set to yes.",
  576.        "id" => "social_fb_like",
  577.        "type" => "selectnormal",
  578.        "options" => array("yes", "no"),
  579.        "std" => "yes"),
  580.  
  581. array( "name" => "Let Users +1 your Posts",
  582.        "desc" => "Choose if you want to display the Google +1 Button next to your Post. Default is set to yes.",
  583.        "id" => "social_google_like",
  584.        "type" => "selectnormal",
  585.        "options" => array("yes", "no"),
  586.        "std" => "yes"),
  587.  
  588. array("type" => "close"),
  589.  
  590. array( "type" => "open",
  591.         "title" => "Portfolio Settings"
  592.         ),
  593.  
  594. array( "name" => "Sort Portfolio Items by",
  595.        "desc" => "Choose how you want to sort your Portfolio items on your Portfolio Page. Default sort order is by date",
  596.        "id" => "portfolio_sort",
  597.        "type" => "selectnormal",
  598.        "options" => array("date", "rand", "title"),
  599.        "std" => "date"),
  600.  
  601. array( "name" => "Order Portfolio Items",
  602.        "desc" => "Choose how you want to order your Portfolio items on your Portfolio Page. Default order is DESC",
  603.        "id" => "portfolio_order",
  604.        "type" => "selectnormal",
  605.        "options" => array("DESC", "ASC"),
  606.        "std" => "DESC"),
  607.  
  608. array( "name" => "Items per Page?",
  609.        "desc" => "How many Portfolio Items would you like to display per Page? Default is set to 9",
  610.        "id" => "portfolio_page",
  611.        "type" => "text",
  612.        "std" => "9"),
  613.  
  614. array("type" => "close"),
  615.  
  616. array( "type" => "open",
  617.         "title" => "Blog Settings"
  618.         ),
  619.  
  620. array( "name" => "Sort Blog Items by",
  621.        "desc" => "Choose how you want to sort your Blog items on your Blog Page. Default sort order is by date",
  622.        "id" => "blog_sort",
  623.        "type" => "selectnormal",
  624.        "options" => array("date", "rand", "title"),
  625.        "std" => "date"),
  626.  
  627. array( "name" => "Order Blog Items",
  628.        "desc" => "Choose how you want to order your Blog items on your Blog Page. Default order is DESC",
  629.        "id" => "blog_order",
  630.        "type" => "selectnormal",
  631.        "options" => array("DESC", "ASC"),
  632.        "std" => "DESC"),
  633.  
  634. array( "name" => "Items per Page?",
  635.        "desc" => "How many Blog Items would you like to display per Page? Default is set to 10",
  636.        "id" => "blog_page",
  637.        "type" => "text",
  638.        "std" => "10"),
  639.  
  640. array("type" => "close")
  641.  
  642. );
  643.  
  644. // create the Options page on the admin side
  645.  
  646. function wpcx_add_admin() {
  647.  
  648.     global $wpcx_themename, $wpcx_shortname, $wpcx_options;
  649.  
  650.         // Saving and Updating the options
  651.        
  652.         if (!empty($_GET['page']) && $_GET['page'] == basename(__FILE__) && !empty($_POST) && check_admin_referer('wpcx_save_theme_options','wpcx_options_nonce')) {
  653.                
  654.                 if (!empty($_REQUEST['action']) && 'save' == $_REQUEST['action']) {
  655.                        
  656.                         $wpcx_cxOptions = array();
  657.                        
  658.                         // print_r($_REQUEST);
  659.                        
  660.                         foreach ($wpcx_options as $wpcx_value) {
  661.                                
  662.                                 if (!empty($wpcx_value['id'])) {
  663.                                        
  664.                                         if(isset($_REQUEST[$wpcx_value['id']])) {
  665.                                        
  666.                                                 $wpcx_cxOptions[$wpcx_value['id']] = esc_attr($_REQUEST[ $wpcx_value['id'] ]);
  667.                                                
  668.                                                 if(strpos($wpcx_cxOptions[$wpcx_value['id']], "http") !== false) {
  669.                                                        
  670.                                                         $wpcx_cxOptions[$wpcx_value['id']] = esc_url($_REQUEST[ $wpcx_value['id'] ]);
  671.                                                        
  672.                                                 }
  673.                                        
  674.                                         }
  675.                                 }
  676.                                
  677.                         }
  678.                        
  679.                         // Logo Upload
  680.                        
  681.                         if(!empty($_FILES["logo_file"])) {
  682.                        
  683.                                 // Upload Logo
  684.                                
  685.                                 $wpcx_dir = TEMPLATEPATH . "/images/logos/";
  686.                                
  687.                                 if (is_writable($wpcx_dir)) {
  688.                                        
  689.                                         if ((($_FILES["logo_file"]["type"] == "image/gif") || ($_FILES["logo_file"]["type"] == "image/jpeg") || ($_FILES["logo_file"]["type"] == "image/png") || ($_FILES["logo_file"]["type"] == "image/pjpeg")) && ($_FILES["logo_file"]["size"] < 1048576)) {
  690.                                                
  691.                                                 if ($_FILES["logo_file"]["error"] > 0){
  692.                                                         echo "Return Code: " . $_FILES["logo_file"]["error"] . "<br />";
  693.                                                 } else {
  694.                                                         $_FILES["logo_file"]["name"] = str_replace(' ', '_' , $_FILES["logo_file"]["name"]);
  695.                                                         if (file_exists($wpcx_dir . $_FILES["logo_file"]["name"])) {
  696.                                                                 echo $_FILES["logo_file"]["name"] . " already exists. ";
  697.                                                         } else {
  698.                                                                 switch($_FILES["logo_file"]["type"]) {
  699.                                                                         case "image/jpeg" : $wpcx_end = ".jpg";
  700.                                                                         break;
  701.                                                                         case "image/png" : $wpcx_end = ".png";
  702.                                                                         break;
  703.                                                                         case "image/gif" : $wpcx_end = ".gif";
  704.                                                                         break;
  705.                                                                 }
  706.                                                                 $wpcx_newname = time().$wpcx_end;
  707.                                                                
  708.                                                                 if(move_uploaded_file($_FILES["logo_file"]["tmp_name"], $wpcx_dir . $wpcx_newname)) {
  709.                                                                        
  710.                                                                         $wpcx_cxOptions['logo_file'] = $wpcx_newname;
  711.                                                                        
  712.                                                                 }
  713.                                                                
  714.                                                         }
  715.                                                 }
  716.                                         }
  717.                                 }
  718.                        
  719.                         }
  720.                        
  721.                         if(!empty($_REQUEST['del_pic'])) {
  722.                                
  723.                                 $wpcx_cxOptions['logo_file'] = "";
  724.                                
  725.                         }
  726.                        
  727.                         update_option('cxOptions', $wpcx_cxOptions);
  728.                
  729.                         if (!empty($wpcx_value['id']) && isset($_REQUEST[ $wpcx_value['id']])) {
  730.                                
  731.                                 update_option('cxOptions', $wpcx_cxOptions);
  732.                                
  733.                         } elseif(!empty($wpcx_value['id'])) {
  734.                                
  735.                                 delete_option( $wpcx_value['id'] );
  736.                                
  737.                         }
  738.                        
  739.                         header("Location: themes.php?page=functions.php&saved=true");
  740.                        
  741.                 } elseif(!empty($_REQUEST['action']) && 'reset' == $_REQUEST['action']) {
  742.                        
  743.                         delete_option('cxOptions');
  744.                        
  745.                         header("Location: themes.php?page=functions.php&reset=true");
  746.                        
  747.                 }                              
  748.                        
  749. }
  750.                
  751.  
  752.     // Add Options page to the admin menu
  753.    
  754.     add_theme_page($wpcx_themename." Options", "$wpcx_themename Options", 'edit_theme_options', basename(__FILE__), 'wpcx_admin');
  755.    
  756. }
  757.  
  758. function wpcx_admin() {
  759.  
  760.         global $wpcx_themename, $wpcx_shortname, $wpcx_options;
  761.    
  762.         ?>
  763.        
  764.         <div class="wrap">
  765.                 <div style="float: left; margin-top: 50px;">
  766.                         <h1><img src="<?php echo get_template_directory_uri();?>/images/logo.gif" /></h1>
  767.                 </div>
  768.                
  769.                 <div style="float: left; margin-left: 150px;">
  770.                         <form action="https://www.paypal.com/cgi-bin/webscr" method="post">
  771.                                 <input type="hidden" name="cmd" value="_donations">
  772.                                 <input type="hidden" name="business" value="dennis.nissle@iwebix.de">
  773.                                 <input type="hidden" name="lc" value="US">
  774.                                 <input type="hidden" name="item_name" value="WP-Creativix Theme Donation">
  775.                                 <input type="hidden" name="currency_code" value="USD">
  776.                                 <input type="hidden" name="bn" value="PP-DonationsBF:btn_donateCC_LG.gif:NonHostedGuest">
  777.                                 <input type="image" src="<?php echo get_template_directory_uri(); ?>/images/donate.png" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
  778.                                 <img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
  779.                         </form>
  780.                 </div>
  781.                            
  782.                 <h2 style="clear: both; margin-left: 5px; margin-bottom: 20px;">WP-Creativix Options Page</h2>
  783.                
  784.                 <?php
  785.                         if ( !empty($_REQUEST['saved']) && $_REQUEST['saved'] ) echo '<div id="message" style="float: left; width: 655px; margin-left: 10px;" class="updated fade"><p><strong>'.$wpcx_themename.' settings saved.</strong></p></div>';
  786.                         if ( !empty($_REQUEST['reset']) && $_REQUEST['reset'] ) echo '<div id="message" style="float: left; width: 655px; margin-left: 10px;" class="updated fade"><p><strong>'.$wpcx_themename.' settings reset.</strong></p></div>';
  787.                 ?>
  788.            
  789.                 <form method="post" enctype="multipart/form-data">
  790.                
  791.                 <?php
  792.                
  793.                 //print_r($options);
  794.                
  795.                 foreach ($wpcx_options as $wpcx_value) {
  796.                        
  797.                         $wpcx_cxOptions = get_option('cxOptions');
  798.                        
  799.                         switch ($wpcx_value['type']) {
  800.                        
  801.                                 case "open": ?>
  802.                                         <div class="container" style="clear: both;background-color: #e8e8e8; border: 1px solid #CCC; padding: 10px; font-size: 11px; width: 650px; margin: 10px; float: left; color: #3b3b3b;">
  803.                                         <h3><?php echo $wpcx_value['title']; ?></h3>
  804.                                 <?php break;
  805.              
  806.                                 case "close": ?>
  807.                                         </div>
  808.                                 <?php break;
  809.              
  810.                                 case 'text': ?>
  811.                                         <div style="margin-top:15px; float: left; clear: both;">
  812.                                                 <?php echo $wpcx_value['name']; ?><br/>
  813.                                                 <input name="<?php echo $wpcx_value['id']; ?>" id="<?php echo $wpcx_value['id']; ?>" type="<?php echo $wpcx_value['type']; ?>" value="<?php if ( !empty($wpcx_cxOptions[$wpcx_value['id']])) { echo esc_attr($wpcx_cxOptions[$wpcx_value['id']]); } else { echo $wpcx_value['std']; } ?>" />
  814.                                         </div>
  815.                                         <div style="width: 350px; float: right; margin-right: 20px; margin-top: 15px; background-color: #fff0b5; border: 4px solid #FFF; padding: 5px; font-size: 10px;">
  816.                                                 <?php echo $wpcx_value['desc']; ?>
  817.                                         </div>
  818.                                 <?php break;
  819.              
  820.                                 case 'textarea': ?>
  821.                                
  822.                                         <div style="margin-top:15px;padding:0; float: left; clear: both;">
  823.                                                 <?php echo $wpcx_value['name']; ?><br/>
  824.                                                 <textarea style="width: 200px; height:70px; font-size: 10px; border: 1px solid #b6b6b6;" name="<?php echo $wpcx_value['id']; ?>" id="<?php echo $wpcx_value['id']; ?>" type="<?php echo $wpcx_value['type']; ?>" cols="" rows=""><?php if ( !empty($wpcx_cxOptions[$wpcx_value['id']])) { echo esc_attr($wpcx_cxOptions[$wpcx_value['id']]); } else { echo $wpcx_value['std']; } ?></textarea>
  825.                                         </div>
  826.                                         <div style="width: 350px; float: right; margin-right: 20px; margin-top: 25px; background-color: #fff0b5; border: 4px solid #FFF; padding: 5px; font-size: 10px;">
  827.                                                 <?php echo $wpcx_value['desc']; ?>
  828.                                         </div>  
  829.                                 <?php break;
  830.                                
  831.                                 case 'upload': ?>
  832.                                
  833.                                         <div style="margin-top:15px;padding:0; float: left; clear: both;">
  834.                                                 <?php echo $wpcx_value['name']; ?><br/>
  835.                                                 <input type="file" name="<?php echo $wpcx_value['id'];?>" id="<?php echo $wpcx_value['id'];?>" />
  836.                                         </div>
  837.                                         <div style="width: 350px; float: right; margin-right: 20px; margin-top: 25px; background-color: #fff0b5; border: 4px solid #FFF; padding: 5px; font-size: 10px;">
  838.                                                 <?php echo $wpcx_value['desc']; ?>
  839.                                         </div>
  840.                                         <?php if ( !empty($wpcx_cxOptions[$wpcx_value['id']])) {
  841.                                                 echo "<div class='logo' style='float: left; clear: both;'><img style='float: left; clear: both;' src='".get_template_directory_uri()."/images/logos/".$wpcx_cxOptions[$wpcx_value['id']]."'/><p style='float: left; clear: both;'><input type='checkbox' name='del_pic' value='del' />Delete Logo</p><input type='hidden' name='logo_file' value='".$wpcx_cxOptions[$wpcx_value['id']]."' /></div>";
  842.                                         }
  843.                                         ?>
  844.                                 <?php break;
  845.              
  846.                                 case 'selectnormal': ?>
  847.                                         <div style="margin-top:15px; padding:0; float: left; clear: both;">
  848.                                                 <?php echo $wpcx_value['name']; ?><br/>
  849.                                                 <select name="<?php echo $wpcx_value['id']; ?>" id="<?php echo $wpcx_value['id']; ?>"><?php foreach ($wpcx_value['options'] as $wpcx_option) { ?><option<?php if(!empty($wpcx_cxOptions[$wpcx_value['id']]) &&$wpcx_cxOptions[$wpcx_value['id']] == $wpcx_option) { echo ' selected="selected"'; } elseif ($wpcx_option == $wpcx_value['std']) { echo ' selected="selected"'; } ?>><?php echo $wpcx_option; ?></option><?php } ?></select>
  850.                                         </div>
  851.                                         <div style="width: 350px; float: right; margin-right: 20px; margin-top: 15px; background-color: #fff0b5; border: 4px solid #FFF; padding: 5px; font-size: 10px;">
  852.                                                 <?php echo $wpcx_value['desc']; ?>
  853.                                         </div>
  854.                                  <?php break;
  855.                    
  856.                                 case "checkbox": ?>
  857.                                         <div style="margin-top:15px; padding:0; float: left; clear: both;">
  858.                                                 <?php echo $wpcx_value['name']; ?><br/>
  859.                                                 <?php if(get_option($wpcx_value['id'])){ $wpcx_checked = "checked=\"checked\""; }else{ $wpcx_checked = "";} ?>
  860.                                                 <input type="checkbox" name="<?php echo $wpcx_value['id']; ?>" id="<?php echo $wpcx_value['id']; ?>" value="true" <?php echo $wpcx_checked; ?> />
  861.                                         </div>
  862.                                         <div style="width: 350px; float: right; margin-right: 20px; margin-top: 15px; background-color: #fff0b5; border: 4px solid #FFF; padding: 5px; font-size: 10px;">
  863.                                                 <?php echo $wpcx_value['desc']; ?>
  864.                                          </div>
  865.                             <?php break;
  866.                         }
  867.                 }
  868.                
  869.         ?>
  870.        
  871.                 <div class="container" style="clear: both; background-color: #e8e8e8; border: 1px solid #CCC; padding: 10px; font-size: 11px; width: 650px; margin: 10px; float: left; color: #3b3b3b;">
  872.                         <p class="submit" style="float: left; margin-right: 20px;">
  873.                                 <input name="save" type="submit" value="Save changes" />
  874.                                 <input type="hidden" name="action" value="save" />
  875.                         </p>
  876.                         <?php wp_nonce_field('wpcx_save_theme_options','wpcx_options_nonce'); ?>
  877.                 </form>
  878.                 <form method="post">
  879.                         <p class="submit">
  880.                                 <input name="reset" type="submit" value="Reset" />
  881.                                 <input type="hidden" name="action" value="reset" />
  882.                         </p>
  883.                 </form>
  884.         </div>
  885.        
  886.         <?php
  887.  
  888. }
  889.  
  890. add_action('admin_menu', 'wpcx_add_admin');
  891.  
  892. ?><?php
  893.  
  894. function bgmpShortcodeCalled()
  895. {
  896.         global $post;
  897.  
  898.         $shortcodePageSlugs = array(
  899.                 'home'
  900.         );
  901.  
  902.         if( $post )
  903.                 if( in_array( $post->post_name, $shortcodePageSlugs ) )
  904.                         add_filter( 'bgmp_map-shortcode-called', '__return_true' );
  905. }
  906. add_action( 'wp', 'bgmpShortcodeCalled' );
  907.  
  908.  
  909. $wpcx_cxOptions = get_option('cxOptions');
  910.  
  911. // Set Content Width
  912.  
  913. $content_width = 600;
  914.  
  915. //Load Styles
  916.  
  917. add_action('wp_print_styles', 'wpcx_add_my_stylesheet');
  918.  
  919. function wpcx_add_my_stylesheet() {
  920.        
  921.         if ( !is_admin() ) {
  922.                 global $wpcx_cxOptions;
  923.                
  924.                 if(!empty($wpcx_cxOptions['colorpicker'])) {
  925.                         $wpcx_colour = $wpcx_cxOptions['colorpicker'];
  926.                 } else {
  927.                         $wpcx_colour = false;
  928.                 }
  929.                
  930.                 $wpcx_main_style = get_template_directory_uri() . '/style.css';
  931.                 wp_register_style('mainStyle', $wpcx_main_style);
  932.                 wp_enqueue_style('mainStyle');
  933.                
  934.                 if($wpcx_colour) {
  935.                         $wpcx_sub_style = get_template_directory_uri() . '/style.php?color=' . $wpcx_colour;
  936.                 } else {
  937.                         $wpcx_sub_style = get_template_directory_uri() . '/style.php';
  938.                 }
  939.                 wp_register_style('wpcx_sub_style', $wpcx_sub_style);
  940.                 wp_enqueue_style('wpcx_sub_style');
  941.         }
  942.        
  943. }
  944.  
  945. add_action('admin_init', 'wpcx_add_to_admin_style');
  946.  
  947. function wpcx_add_to_admin_style() {
  948.        
  949.         $wpcx_admin_style = get_template_directory_uri() . '/admin.css';
  950.         wp_register_style('wpcx_admin_style', $wpcx_admin_style);
  951.         wp_enqueue_style('wpcx_admin_style');
  952.        
  953. }
  954.  
  955. function wpcx_add_margin_header() {
  956.        
  957.         global $wpcx_cxOptions;
  958.                
  959.         if(!empty($wpcx_cxOptions["logo_margin"])) {
  960.  
  961.                 echo "<style type='text/css'>#header { margin-top: " . $wpcx_cxOptions["logo_margin"] . "px;}</style>";
  962.  
  963.         }
  964.        
  965. }
  966.  
  967. add_action('wp_head', 'wpcx_add_margin_header');
  968.  
  969. //Load JS
  970.  
  971. add_action('init', 'wpcx_add_my_scripts');
  972.  
  973. function wpcx_add_my_scripts() {
  974.        
  975.         if ( !is_admin() ) {
  976.            
  977.                 wp_register_script('wpcx_jquery.cycle', get_template_directory_uri() . '/scripts/jquery.cycle.all.js', array('jquery'), '1.0' );
  978.                 wp_enqueue_script('wpcx_jquery.cycle');
  979.                 wp_register_script('wpcx_jquery.superfish', get_template_directory_uri() . '/scripts/jquery.superfish.js', array('jquery'), '1.0' );
  980.                 wp_enqueue_script('wpcx_jquery.superfish');
  981.                 wp_register_script('wpcx_jquery.fredsel', get_template_directory_uri() . '/scripts/jquery.carouFredSel-2.3.1.js', array('jquery'), '1.0' );
  982.                 wp_enqueue_script('wpcx_jquery.fredsel');
  983.                 wp_register_script('wpcx_jquery.fancybox', get_template_directory_uri() . '/scripts/jquery.fancybox-1.3.4.pack.js', array('jquery'), '1.0' );
  984.                 wp_enqueue_script('wpcx_jquery.fancybox');
  985.                 wp_register_script('wpcx_custom', get_template_directory_uri() . '/scripts/custom.js', array('jquery'), '1.0' );
  986.                 wp_enqueue_script('wpcx_custom');
  987.            
  988.         } else {
  989.            
  990.                 wp_register_script('wpcx_jquery.picker', get_template_directory_uri() . '/scripts/jquery.picker.js', array('jquery'), '1.0' );
  991.                 wp_enqueue_script('wpcx_jquery.picker');
  992.                 wp_register_script('wpcx_admin_custom', get_template_directory_uri() . '/scripts/admin_custom.js', array('jquery'), '1.0' );
  993.                 wp_enqueue_script('wpcx_admin_custom');
  994.            
  995.         }
  996. }
  997.  
  998. // Custom Logo Support
  999.  
  1000. define( 'HEADER_IMAGE', '%s/images/logo.png' );
  1001.  
  1002. define( 'HEADER_IMAGE_WIDTH', apply_filters( '', 520 ) );
  1003.  
  1004. define( 'HEADER_IMAGE_HEIGHT', apply_filters( '', 155 ) );
  1005.  
  1006. define( 'HEADER_TEXTCOLOR', '' );
  1007.  
  1008. define( 'NO_HEADER_TEXT', true );
  1009.  
  1010. add_custom_image_header( '', 'wpcx_admin_header_style' );
  1011.  
  1012. //Add custom post type "Portfolio"
  1013.  
  1014. function wpcx_post_type_myportfolio() {
  1015.        
  1016. register_post_type(
  1017.         'myportfolio',
  1018.         array('label' => 'Portfolio',
  1019.                 'singular_label' => 'Portfolio',
  1020.                 'public' => true,
  1021.                 'show_ui' => true,
  1022.                 'capability_type' => 'post',
  1023.                 'hierarchical' => false,
  1024.                 'rewrite' => array("slug" => "portfolio-item", "with_front" => false),
  1025.                 'supports' => array('title','editor','custom-fields','revisions','thumbnail'),
  1026.                 'menu_position' => 4
  1027.         )
  1028. );
  1029.         register_taxonomy( 'portfolio', 'myportfolio', array( 'hierarchical' => true, 'label' => 'Portfolio Categories' ) );
  1030.        
  1031. }
  1032.  
  1033. add_action('init','wpcx_post_type_myportfolio');
  1034.  
  1035. if (!function_exists( 'wpcx_admin_header_style' )) {
  1036.        
  1037.         function wpcx_admin_header_style() { ?>
  1038.  
  1039.                 <style type="text/css">
  1040.                
  1041.                 #headimg {
  1042.                         height: <?php echo HEADER_IMAGE_HEIGHT; ?>px;
  1043.                         width: <?php echo HEADER_IMAGE_WIDTH; ?>px;
  1044.                 }
  1045.                
  1046.                 #headimg h1, #headimg #desc {
  1047.                         display: none;
  1048.                 }
  1049.                
  1050.                 </style>
  1051.         <?php }
  1052. }
  1053.  
  1054. //WP 3.0 Menu
  1055.  
  1056. add_action('init', 'wpcx_register_custom_menu');
  1057.  
  1058. function wpcx_register_custom_menu() {
  1059.         register_nav_menu('footer_menu', 'Footer Menu');
  1060.         register_nav_menu('nav_menu', 'Navigation Menu');
  1061. }
  1062.  
  1063. //Remove wp_nav wrapping
  1064.  
  1065. function wpcx_my_nav_unlister( $menu ){
  1066.         return preg_replace( array( '#^<ul[^>]*>#', '#</ul>$#' ), '', $menu );
  1067. }
  1068.  
  1069. add_filter( 'wp_nav_menu', 'wpcx_my_nav_unlister' );
  1070.  
  1071. // Fallback Nav Menus
  1072.  
  1073. function wpcx_default_menu() {
  1074.        
  1075.         echo "<li><a href='" . home_url() . "/'>Home</a></li>";
  1076.  
  1077. }
  1078.  
  1079. // Cut some text
  1080.  
  1081. function wpcx_cut_text($text, $chars, $points = "...") {
  1082.         $length = strlen($text);
  1083.         if($length <= $chars) {
  1084.                 return $text;
  1085.         } else {
  1086.                 return substr($text, 0, $chars)." ".$points;
  1087.         }
  1088. }
  1089.  
  1090. // Get WP Generated thumb
  1091.  
  1092. function wpcx_get_wp_generated_thumb($position) {
  1093.         global $post_id;
  1094.         $thumb = get_the_post_thumbnail($post_id, $position);
  1095.         $thumb = explode("\"", $thumb);
  1096.         if(!empty($thumb[5])) {
  1097.                 return $thumb[5];
  1098.         }
  1099. }
  1100.  
  1101. if (function_exists('add_image_size')) {
  1102.         add_image_size( 'slideshow', 480, 210, true );
  1103.         add_image_size( 'slideshow_thumb', 100, 75, true );
  1104.         add_image_size( 'reference', 250, 130, true );
  1105.         add_image_size( 'feat_thumb', 295, 150, true );
  1106. }
  1107.  
  1108. // Styling & Script Functions
  1109.  
  1110. function wpcx_script() {
  1111.        
  1112.         global $wpcx_cxOptions;
  1113.        
  1114.         if(!empty($wpcx_cxOptions["slide_effect"])) {
  1115.                
  1116.                 $wpcx_slide_effect = $wpcx_cxOptions["slide_effect"];
  1117.                
  1118.         } else {
  1119.                
  1120.                 $wpcx_slide_effect = "scrollRight";
  1121.                
  1122.         }
  1123.        
  1124.         if(!empty($wpcx_cxOptions["slide_speed"])) {
  1125.                
  1126.                 $wpcx_slide_speed = $wpcx_cxOptions["slide_speed"];
  1127.                
  1128.         } else {
  1129.                
  1130.                 $wpcx_slide_speed = 500;
  1131.                
  1132.         }
  1133.        
  1134.         if(!empty($wpcx_cxOptions["slide_duration"])) {
  1135.                
  1136.                 $wpcx_slide_duration = $wpcx_cxOptions["slide_duration"];
  1137.                
  1138.         } else {
  1139.                
  1140.                 $wpcx_slide_duration = 3000;
  1141.                
  1142.         }
  1143.        
  1144.        
  1145.        
  1146.         $wpcx_script = '<script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>
  1147.         <script type="text/javascript">
  1148.                         jQuery(document).ready(function($) {
  1149.                                 jQuery("ul#slideshow").cycle({
  1150.                                         fx:             "'.$wpcx_slide_effect.'",
  1151.                                         speed:          '.$wpcx_slide_speed.',
  1152.                                         timeout:        '.$wpcx_slide_duration.',
  1153.                                         pager:          "ul#slide_navigation",
  1154.                         pagerAnchorBuilder: function(idx, slide) {
  1155.                             // return selector string for existing anchor
  1156.                             return "#slide_navigation li:eq(" + idx + ") a";
  1157.                         }
  1158.                 });
  1159.        
  1160.         });
  1161.  
  1162.         </script>';
  1163.        
  1164.         echo $wpcx_script;
  1165.        
  1166. }
  1167.  
  1168. add_action('wp_head', 'wpcx_script');
  1169.  
  1170. function wpcx_style() {
  1171.        
  1172.         $wpcx_style = "";
  1173.        
  1174.         global $wpcx_cxOptions;
  1175.        
  1176.         if(!empty($wpcx_cxOptions["logo_size"])) {
  1177.                
  1178.                 $wpcx_logo_size = $wpcx_cxOptions["logo_size"];
  1179.                
  1180.                 $style = '<style type="text/css">
  1181.                 #logoname a {
  1182.                 font-size: '.$wpcx_logo_size.'px !important;
  1183.                 }
  1184.                 </style>
  1185.                 ';
  1186.                
  1187.         }
  1188.  
  1189.         if(empty($wpcx_cxOptions["logo_file"])) {
  1190.                
  1191.                
  1192.                 $wpcx_style .= '<style type="text/css">
  1193.                 #logoname {
  1194.                 margin-top: 12px;
  1195.                 }
  1196.                 </style>
  1197.                 ';
  1198.  
  1199.         }
  1200.        
  1201.         if(!empty($wpcx_style)) {
  1202.                
  1203.                 echo $wpcx_style;
  1204.        
  1205.         }
  1206.        
  1207. }
  1208.  
  1209. add_action('wp_head', 'wpcx_style');
  1210.  
  1211. function wpcx_list_pages() {
  1212.        
  1213.         echo "<li><a href='".get_bloginfo('url')."'>Home</a>";
  1214.         wp_list_pages('title_li=');
  1215.        
  1216. }
  1217.  
  1218. // Featured Options
  1219.  
  1220. add_action("admin_init", "wpcx_admin_init");
  1221. add_action('save_post', 'wpcx_save_feat');
  1222.  
  1223. function wpcx_admin_init(){
  1224.         add_meta_box("page_feat", "Creativix Options", "wpcx_feat_options", "page", "normal", "high");
  1225.         add_meta_box("post_feat", "Creativix Options", "wpcx_feat_options", "post", "normal", "high");
  1226. }
  1227.  
  1228. function wpcx_feat_options(){
  1229.        
  1230.         global $post;
  1231.         $wpcx_custom = get_post_custom($post->ID);
  1232.         if(!empty($wpcx_custom)) {
  1233.                 if(!empty($wpcx_custom["feat_slideshow"][0])) {
  1234.                         $wpcx_featured = $wpcx_custom["feat_slideshow"][0];
  1235.                 }
  1236.                 if(!empty($wpcx_custom["feat_front"][0])) {
  1237.                         $wpcx_feat_front = $wpcx_custom["feat_front"][0];
  1238.                 }
  1239.         }
  1240. ?>
  1241.         <div class="inside">
  1242.                 <table class="form-table">
  1243.                         <tr>
  1244.                                 <th><label for="featured">Feature in Slideshow?</label></th>
  1245.                                 <td><input type="checkbox" name="featured" value="1" <?php if(isset($wpcx_featured) && $wpcx_featured == 1) { echo "checked='checked'";} ?></td>
  1246.                         </tr>
  1247.                         <tr>
  1248.                                 <th><label for="featured">Feature on frontpage?</label></th>
  1249.                                 <td><input type="checkbox" name="feat_front" value="1" <?php if(isset($wpcx_feat_front) && $wpcx_feat_front == 1) { echo "checked='checked'";} ?></td>
  1250.                         </tr>
  1251.                 </table>
  1252.         </div>
  1253. <?php
  1254. }
  1255.  
  1256. function wpcx_save_feat(){
  1257.        
  1258.         global $post;
  1259.        
  1260.         if($post->post_type == "post" OR $post->post_type == "page") {
  1261.        
  1262.                 if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE )
  1263.                 return $post_id;
  1264.                
  1265.                
  1266.                 if(isset($_POST["featured"])) {
  1267.                        
  1268.                         update_post_meta($post->ID, "feat_slideshow", $_POST["featured"]);
  1269.                        
  1270.                 } else {
  1271.                        
  1272.                         delete_post_meta($post->ID, "feat_slideshow", '');
  1273.                        
  1274.                 }
  1275.                
  1276.                 if(isset($_POST["feat_front"])) {
  1277.                        
  1278.                         update_post_meta($post->ID, "feat_front", $_POST["feat_front"]);
  1279.                        
  1280.                 } else {
  1281.                        
  1282.                         delete_post_meta($post->ID, "feat_front", '');
  1283.                        
  1284.                 }
  1285.        
  1286.         }
  1287.        
  1288. }
  1289.  
  1290.  
  1291. //Check for Post Thumbnail Support
  1292.  
  1293. if ( function_exists( 'add_theme_support' ) )
  1294. add_theme_support( 'post-thumbnails' );
  1295.  
  1296. // Register Sidebar
  1297.  
  1298. if ( function_exists('register_sidebar') )
  1299.     register_sidebar();
  1300.  
  1301. // Add RSS
  1302.  
  1303. add_theme_support('automatic-feed-links');
  1304.  
  1305. // Custom BG
  1306.  
  1307. add_custom_background();
  1308.  
  1309. // Editor Style
  1310.  
  1311. add_editor_style();
  1312.  
  1313. //Loading Theme Options Framework
  1314.  
  1315. $wpcx_themename = "WP-Creativix";
  1316. $wpcx_shortname = "Creativix";
  1317.  
  1318. $wpcx_options = array (
  1319.        
  1320. array( "type" => "open",
  1321. "title" => "Frontpage Settings"
  1322. ),
  1323.  
  1324. array( "name" => "Activate Slideshow on Frontpage?",
  1325.        "desc" => "Decide if you want to show the big Slideshow on Frontpage. By default the Slideshow will be shown.",
  1326.        "id" => "slide_show",
  1327.        "type" => "selectnormal",
  1328.        "options" => array("yes", "no"),
  1329.        "std" => "yes"),
  1330.  
  1331. array( "name" => "Limit Posts/Pages in Slideshow",
  1332.        "desc" => "Set maximum amount of posts/pages to be shown in the slideshow. Leave empty if you don't want to limit them.",
  1333.        "id" => "slide_max",
  1334.        "type" => "text",
  1335.        "std" => ""),
  1336.  
  1337. array( "name" => "Sort Posts/Pages in Slideshow",
  1338.        "desc" => "Choose how you want to sort your posts/pages in the Slideshow. Default sort order is by date",
  1339.        "id" => "slide_sort",
  1340.        "type" => "selectnormal",
  1341.        "options" => array("post_date", "rand", "title"),
  1342.        "std" => "post_date"),
  1343.  
  1344. array( "name" => "Order Posts/Pages in Slideshow",
  1345.        "desc" => "Choose how you want to order your posts/pages in the Slideshow. Default order is DESC",
  1346.        "id" => "slide_order",
  1347.        "type" => "selectnormal",
  1348.        "options" => array("DESC", "ASC"),
  1349.        "std" => "DESC"),
  1350.  
  1351. array( "name" => "Choose Sliding Effect",
  1352.        "desc" => "Choose an effect that will be applied for the Slideshow. Defaul ist scrollRight.",
  1353.        "id" => "slide_effect",
  1354.        "type" => "selectnormal",
  1355.        "options" => array("scrollRight", "fade", 'scrollUp', 'scrollDown', 'blindZ', 'fadeZoom'),
  1356.        "std" => "scrollRight"),
  1357.  
  1358. array( "name" => "Slideshow Transition Speed",
  1359.        "desc" => "Set the Speed for the slideshow's transition. Default ist set to 500 (ms)",
  1360.        "id" => "slide_speed",
  1361.        "type" => "text",
  1362.        "std" => "500"),
  1363.  
  1364. array( "name" => "Slideshow Duration",
  1365.        "desc" => "Set duration for each single Slide Item. Default is set to 3000 (ms)",
  1366.        "id" => "slide_duration",
  1367.        "type" => "text",
  1368.        "std" => "3000"),
  1369.  
  1370. array( "name" => "Sort Posts/Pages for Featured Posts on Frontage",
  1371.        "desc" => "Choose how you want to sort your posts/pages in the Featured Area on Frontage. Default sort order is by date",
  1372.        "id" => "featured_sort",
  1373.        "type" => "selectnormal",
  1374.        "options" => array("post_date", "rand", "title"),
  1375.        "std" => "post_date"),
  1376.  
  1377. array( "name" => "Order Posts/Pages for Featured Posts on Frontpage",
  1378.        "desc" => "Choose how you want to order your posts/pages in the Featured Area. Default order is DESC",
  1379.        "id" => "featured_order",
  1380.        "type" => "selectnormal",
  1381.        "options" => array("DESC", "ASC"),
  1382.        "std" => "DESC"),
  1383.  
  1384. array( "name" => "Sort Posts for Latest Articles",
  1385.        "desc" => "Choose how you want to sort your latest Articles displayed next to featured Articles. Default sort order is by date",
  1386.        "id" => "articles_sort",
  1387.        "type" => "selectnormal",
  1388.        "options" => array("date", "rand", "title"),
  1389.        "std" => "date"),
  1390.  
  1391. array( "name" => "Order Posts for Latest Articles",
  1392.        "desc" => "Choose how you want to order your latest Articles displayed next to featured Articles. Default order is DESC",
  1393.        "id" => "articles_order",
  1394.        "type" => "selectnormal",
  1395.        "options" => array("DESC", "ASC"),
  1396.        "std" => "DESC"),
  1397.  
  1398. array("type" => "close"),
  1399.  
  1400. array( "type" => "open",
  1401.         "title" => "Styling Settings"
  1402.         ),
  1403.  
  1404. array( "name" => "Logo Font Size",
  1405.        "desc" => "Choose a font size for the Logo. Default font size is set to 26px.",
  1406.        "id" => "logo_size",
  1407.        "type" => "text",
  1408.        "std" => "26"),
  1409.  
  1410. array( "name" => "Logo Text",
  1411.        "desc" => "Choose text for the logo. Leave this empty to use your Wordpress Blog Title instead.",
  1412.        "id" => "logo_name",
  1413.        "type" => "text",
  1414.        "std" => ""),
  1415.  
  1416. array( "name" => "Logo/Nav Margin",
  1417.        "desc" => "Choose how many space should be between Social Menu and Navigation/Logo in px.",
  1418.        "id" => "logo_margin",
  1419.        "type" => "text",
  1420.        "std" => ""),
  1421.  
  1422. array( "name" => "Logo Upload",
  1423.        "desc" => "Upload your own Logo. The Logo will not be cropped/resized. You must apply correct width/height before uploading. (Folder wp-creativix/images/logos/ must be writeable)",
  1424.        "id" => "logo_file",
  1425.        "type" => "upload",
  1426.        "std" => ""),
  1427.  
  1428. array( "name" => "Choose an highlight Colour",
  1429.        "desc" => "Click on the input field and choose a highlight colour with the help of the colour-picker.",
  1430.        "id" => "colorpicker",
  1431.        "type" => "text",
  1432.        "std" => "939393"),
  1433.  
  1434. array("type" => "close"),
  1435.  
  1436. array( "type" => "open",
  1437.         "title" => "Social Media Settings"
  1438.         ),
  1439.  
  1440. array( "name" => "Facebook Profile URL",
  1441.        "desc" => "If you want to show the icon, enter the URL (http://..) that points to your Facebook profile. (Leave empty to not show the icon)",
  1442.        "id" => "social_facebook",
  1443.        "type" => "text",
  1444.        "std" => ""),
  1445.  
  1446. array( "name" => "Linkedin Profile ID",
  1447.        "desc" => "Insert your Linkedin Profile ID to show the Linkedin Icon in the Header. (Leave empty to not show the icon)",
  1448.        "id" => "social_linkedin",
  1449.        "type" => "text",
  1450.        "std" => ""),
  1451.  
  1452. array( "name" => "Twitter Username",
  1453.        "desc" => "Insert your Twitter Username to show the Twitter Icon in the Header. (Leave empty to not show the icon)",
  1454.        "id" => "social_twitter",
  1455.        "type" => "text",
  1456.        "std" => ""),
  1457.  
  1458. array( "name" => "Show RSS Icon in Header?",
  1459.        "desc" => "Choose if you want to display the RSS Icon in the Header. Default is set to yes.",
  1460.        "id" => "social_rss",
  1461.        "type" => "selectnormal",
  1462.        "options" => array("yes", "no"),
  1463.        "std" => "yes"),
  1464.  
  1465. array( "name" => "Let Users like posts on Facebook",
  1466.        "desc" => "Choose if you want to display the facebook-like-button next to your Post. Default is set to yes.",
  1467.        "id" => "social_fb_like",
  1468.        "type" => "selectnormal",
  1469.        "options" => array("yes", "no"),
  1470.        "std" => "yes"),
  1471.  
  1472. array( "name" => "Let Users +1 your Posts",
  1473.        "desc" => "Choose if you want to display the Google +1 Button next to your Post. Default is set to yes.",
  1474.        "id" => "social_google_like",
  1475.        "type" => "selectnormal",
  1476.        "options" => array("yes", "no"),
  1477.        "std" => "yes"),
  1478.  
  1479. array("type" => "close"),
  1480.  
  1481. array( "type" => "open",
  1482.         "title" => "Portfolio Settings"
  1483.         ),
  1484.  
  1485. array( "name" => "Sort Portfolio Items by",
  1486.        "desc" => "Choose how you want to sort your Portfolio items on your Portfolio Page. Default sort order is by date",
  1487.        "id" => "portfolio_sort",
  1488.        "type" => "selectnormal",
  1489.        "options" => array("date", "rand", "title"),
  1490.        "std" => "date"),
  1491.  
  1492. array( "name" => "Order Portfolio Items",
  1493.        "desc" => "Choose how you want to order your Portfolio items on your Portfolio Page. Default order is DESC",
  1494.        "id" => "portfolio_order",
  1495.        "type" => "selectnormal",
  1496.        "options" => array("DESC", "ASC"),
  1497.        "std" => "DESC"),
  1498.  
  1499. array( "name" => "Items per Page?",
  1500.        "desc" => "How many Portfolio Items would you like to display per Page? Default is set to 9",
  1501.        "id" => "portfolio_page",
  1502.        "type" => "text",
  1503.        "std" => "9"),
  1504.  
  1505. array("type" => "close"),
  1506.  
  1507. array( "type" => "open",
  1508.         "title" => "Blog Settings"
  1509.         ),
  1510.  
  1511. array( "name" => "Sort Blog Items by",
  1512.        "desc" => "Choose how you want to sort your Blog items on your Blog Page. Default sort order is by date",
  1513.        "id" => "blog_sort",
  1514.        "type" => "selectnormal",
  1515.        "options" => array("date", "rand", "title"),
  1516.        "std" => "date"),
  1517.  
  1518. array( "name" => "Order Blog Items",
  1519.        "desc" => "Choose how you want to order your Blog items on your Blog Page. Default order is DESC",
  1520.        "id" => "blog_order",
  1521.        "type" => "selectnormal",
  1522.        "options" => array("DESC", "ASC"),
  1523.        "std" => "DESC"),
  1524.  
  1525. array( "name" => "Items per Page?",
  1526.        "desc" => "How many Blog Items would you like to display per Page? Default is set to 10",
  1527.        "id" => "blog_page",
  1528.        "type" => "text",
  1529.        "std" => "10"),
  1530.  
  1531. array("type" => "close")
  1532.  
  1533. );
  1534.  
  1535. // create the Options page on the admin side
  1536.  
  1537. function wpcx_add_admin() {
  1538.  
  1539.     global $wpcx_themename, $wpcx_shortname, $wpcx_options;
  1540.  
  1541.         // Saving and Updating the options
  1542.        
  1543.         if (!empty($_GET['page']) && $_GET['page'] == basename(__FILE__) && !empty($_POST) && check_admin_referer('wpcx_save_theme_options','wpcx_options_nonce')) {
  1544.                
  1545.                 if (!empty($_REQUEST['action']) && 'save' == $_REQUEST['action']) {
  1546.                        
  1547.                         $wpcx_cxOptions = array();
  1548.                        
  1549.                         // print_r($_REQUEST);
  1550.                        
  1551.                         foreach ($wpcx_options as $wpcx_value) {
  1552.                                
  1553.                                 if (!empty($wpcx_value['id'])) {
  1554.                                        
  1555.                                         if(isset($_REQUEST[$wpcx_value['id']])) {
  1556.                                        
  1557.                                                 $wpcx_cxOptions[$wpcx_value['id']] = esc_attr($_REQUEST[ $wpcx_value['id'] ]);
  1558.                                                
  1559.                                                 if(strpos($wpcx_cxOptions[$wpcx_value['id']], "http") !== false) {
  1560.                                                        
  1561.                                                         $wpcx_cxOptions[$wpcx_value['id']] = esc_url($_REQUEST[ $wpcx_value['id'] ]);
  1562.                                                        
  1563.                                                 }
  1564.                                        
  1565.                                         }
  1566.                                 }
  1567.                                
  1568.                         }
  1569.                        
  1570.                         // Logo Upload
  1571.                        
  1572.                         if(!empty($_FILES["logo_file"])) {
  1573.                        
  1574.                                 // Upload Logo
  1575.                                
  1576.                                 $wpcx_dir = TEMPLATEPATH . "/images/logos/";
  1577.                                
  1578.                                 if (is_writable($wpcx_dir)) {
  1579.                                        
  1580.                                         if ((($_FILES["logo_file"]["type"] == "image/gif") || ($_FILES["logo_file"]["type"] == "image/jpeg") || ($_FILES["logo_file"]["type"] == "image/png") || ($_FILES["logo_file"]["type"] == "image/pjpeg")) && ($_FILES["logo_file"]["size"] < 1048576)) {
  1581.                                                
  1582.                                                 if ($_FILES["logo_file"]["error"] > 0){
  1583.                                                         echo "Return Code: " . $_FILES["logo_file"]["error"] . "<br />";
  1584.                                                 } else {
  1585.                                                         $_FILES["logo_file"]["name"] = str_replace(' ', '_' , $_FILES["logo_file"]["name"]);
  1586.                                                         if (file_exists($wpcx_dir . $_FILES["logo_file"]["name"])) {
  1587.                                                                 echo $_FILES["logo_file"]["name"] . " already exists. ";
  1588.                                                         } else {
  1589.                                                                 switch($_FILES["logo_file"]["type"]) {
  1590.                                                                         case "image/jpeg" : $wpcx_end = ".jpg";
  1591.                                                                         break;
  1592.                                                                         case "image/png" : $wpcx_end = ".png";
  1593.                                                                         break;
  1594.                                                                         case "image/gif" : $wpcx_end = ".gif";
  1595.                                                                         break;
  1596.                                                                 }
  1597.                                                                 $wpcx_newname = time().$wpcx_end;
  1598.                                                                
  1599.                                                                 if(move_uploaded_file($_FILES["logo_file"]["tmp_name"], $wpcx_dir . $wpcx_newname)) {
  1600.                                                                        
  1601.                                                                         $wpcx_cxOptions['logo_file'] = $wpcx_newname;
  1602.                                                                        
  1603.                                                                 }
  1604.                                                                
  1605.                                                         }
  1606.                                                 }
  1607.                                         }
  1608.                                 }
  1609.                        
  1610.                         }
  1611.                        
  1612.                         if(!empty($_REQUEST['del_pic'])) {
  1613.                                
  1614.                                 $wpcx_cxOptions['logo_file'] = "";
  1615.                                
  1616.                         }
  1617.                        
  1618.                         update_option('cxOptions', $wpcx_cxOptions);
  1619.                
  1620.                         if (!empty($wpcx_value['id']) && isset($_REQUEST[ $wpcx_value['id']])) {
  1621.                                
  1622.                                 update_option('cxOptions', $wpcx_cxOptions);
  1623.                                
  1624.                         } elseif(!empty($wpcx_value['id'])) {
  1625.                                
  1626.                                 delete_option( $wpcx_value['id'] );
  1627.                                
  1628.                         }
  1629.                        
  1630.                         header("Location: themes.php?page=functions.php&saved=true");
  1631.                        
  1632.                 } elseif(!empty($_REQUEST['action']) && 'reset' == $_REQUEST['action']) {
  1633.                        
  1634.                         delete_option('cxOptions');
  1635.                        
  1636.                         header("Location: themes.php?page=functions.php&reset=true");
  1637.                        
  1638.                 }                              
  1639.                        
  1640. }
  1641.                
  1642.  
  1643.     // Add Options page to the admin menu
  1644.    
  1645.     add_theme_page($wpcx_themename." Options", "$wpcx_themename Options", 'edit_theme_options', basename(__FILE__), 'wpcx_admin');
  1646.    
  1647. }
  1648.  
  1649. function wpcx_admin() {
  1650.  
  1651.         global $wpcx_themename, $wpcx_shortname, $wpcx_options;
  1652.    
  1653.         ?>
  1654.        
  1655.         <div class="wrap">
  1656.                 <div style="float: left; margin-top: 50px;">
  1657.                         <h1><img src="<?php echo get_template_directory_uri();?>/images/logo.gif" /></h1>
  1658.                 </div>
  1659.                
  1660.                 <div style="float: left; margin-left: 150px;">
  1661.                         <form action="https://www.paypal.com/cgi-bin/webscr" method="post">
  1662.                                 <input type="hidden" name="cmd" value="_donations">
  1663.                                 <input type="hidden" name="business" value="dennis.nissle@iwebix.de">
  1664.                                 <input type="hidden" name="lc" value="US">
  1665.                                 <input type="hidden" name="item_name" value="WP-Creativix Theme Donation">
  1666.                                 <input type="hidden" name="currency_code" value="USD">
  1667.                                 <input type="hidden" name="bn" value="PP-DonationsBF:btn_donateCC_LG.gif:NonHostedGuest">
  1668.                                 <input type="image" src="<?php echo get_template_directory_uri(); ?>/images/donate.png" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
  1669.                                 <img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
  1670.                         </form>
  1671.                 </div>
  1672.                            
  1673.                 <h2 style="clear: both; margin-left: 5px; margin-bottom: 20px;">WP-Creativix Options Page</h2>
  1674.                
  1675.                 <?php
  1676.                         if ( !empty($_REQUEST['saved']) && $_REQUEST['saved'] ) echo '<div id="message" style="float: left; width: 655px; margin-left: 10px;" class="updated fade"><p><strong>'.$wpcx_themename.' settings saved.</strong></p></div>';
  1677.                         if ( !empty($_REQUEST['reset']) && $_REQUEST['reset'] ) echo '<div id="message" style="float: left; width: 655px; margin-left: 10px;" class="updated fade"><p><strong>'.$wpcx_themename.' settings reset.</strong></p></div>';
  1678.                 ?>
  1679.            
  1680.                 <form method="post" enctype="multipart/form-data">
  1681.                
  1682.                 <?php
  1683.                
  1684.                 //print_r($options);
  1685.                
  1686.                 foreach ($wpcx_options as $wpcx_value) {
  1687.                        
  1688.                         $wpcx_cxOptions = get_option('cxOptions');
  1689.                        
  1690.                         switch ($wpcx_value['type']) {
  1691.                        
  1692.                                 case "open": ?>
  1693.                                         <div class="container" style="clear: both;background-color: #e8e8e8; border: 1px solid #CCC; padding: 10px; font-size: 11px; width: 650px; margin: 10px; float: left; color: #3b3b3b;">
  1694.                                         <h3><?php echo $wpcx_value['title']; ?></h3>
  1695.                                 <?php break;
  1696.              
  1697.                                 case "close": ?>
  1698.                                         </div>
  1699.                                 <?php break;
  1700.              
  1701.                                 case 'text': ?>
  1702.                                         <div style="margin-top:15px; float: left; clear: both;">
  1703.                                                 <?php echo $wpcx_value['name']; ?><br/>
  1704.                                                 <input name="<?php echo $wpcx_value['id']; ?>" id="<?php echo $wpcx_value['id']; ?>" type="<?php echo $wpcx_value['type']; ?>" value="<?php if ( !empty($wpcx_cxOptions[$wpcx_value['id']])) { echo esc_attr($wpcx_cxOptions[$wpcx_value['id']]); } else { echo $wpcx_value['std']; } ?>" />
  1705.                                         </div>
  1706.                                         <div style="width: 350px; float: right; margin-right: 20px; margin-top: 15px; background-color: #fff0b5; border: 4px solid #FFF; padding: 5px; font-size: 10px;">
  1707.                                                 <?php echo $wpcx_value['desc']; ?>
  1708.                                         </div>
  1709.                                 <?php break;
  1710.              
  1711.                                 case 'textarea': ?>
  1712.                                
  1713.                                         <div style="margin-top:15px;padding:0; float: left; clear: both;">
  1714.                                                 <?php echo $wpcx_value['name']; ?><br/>
  1715.                                                 <textarea style="width: 200px; height:70px; font-size: 10px; border: 1px solid #b6b6b6;" name="<?php echo $wpcx_value['id']; ?>" id="<?php echo $wpcx_value['id']; ?>" type="<?php echo $wpcx_value['type']; ?>" cols="" rows=""><?php if ( !empty($wpcx_cxOptions[$wpcx_value['id']])) { echo esc_attr($wpcx_cxOptions[$wpcx_value['id']]); } else { echo $wpcx_value['std']; } ?></textarea>
  1716.                                         </div>
  1717.                                         <div style="width: 350px; float: right; margin-right: 20px; margin-top: 25px; background-color: #fff0b5; border: 4px solid #FFF; padding: 5px; font-size: 10px;">
  1718.                                                 <?php echo $wpcx_value['desc']; ?>
  1719.                                         </div>  
  1720.                                 <?php break;
  1721.                                
  1722.                                 case 'upload': ?>
  1723.                                
  1724.                                         <div style="margin-top:15px;padding:0; float: left; clear: both;">
  1725.                                                 <?php echo $wpcx_value['name']; ?><br/>
  1726.                                                 <input type="file" name="<?php echo $wpcx_value['id'];?>" id="<?php echo $wpcx_value['id'];?>" />
  1727.                                         </div>
  1728.                                         <div style="width: 350px; float: right; margin-right: 20px; margin-top: 25px; background-color: #fff0b5; border: 4px solid #FFF; padding: 5px; font-size: 10px;">
  1729.                                                 <?php echo $wpcx_value['desc']; ?>
  1730.                                         </div>
  1731.                                         <?php if ( !empty($wpcx_cxOptions[$wpcx_value['id']])) {
  1732.                                                 echo "<div class='logo' style='float: left; clear: both;'><img style='float: left; clear: both;' src='".get_template_directory_uri()."/images/logos/".$wpcx_cxOptions[$wpcx_value['id']]."'/><p style='float: left; clear: both;'><input type='checkbox' name='del_pic' value='del' />Delete Logo</p><input type='hidden' name='logo_file' value='".$wpcx_cxOptions[$wpcx_value['id']]."' /></div>";
  1733.                                         }
  1734.                                         ?>
  1735.                                 <?php break;
  1736.              
  1737.                                 case 'selectnormal': ?>
  1738.                                         <div style="margin-top:15px; padding:0; float: left; clear: both;">
  1739.                                                 <?php echo $wpcx_value['name']; ?><br/>
  1740.                                                 <select name="<?php echo $wpcx_value['id']; ?>" id="<?php echo $wpcx_value['id']; ?>"><?php foreach ($wpcx_value['options'] as $wpcx_option) { ?><option<?php if(!empty($wpcx_cxOptions[$wpcx_value['id']]) &&$wpcx_cxOptions[$wpcx_value['id']] == $wpcx_option) { echo ' selected="selected"'; } elseif ($wpcx_option == $wpcx_value['std']) { echo ' selected="selected"'; } ?>><?php echo $wpcx_option; ?></option><?php } ?></select>
  1741.                                         </div>
  1742.                                         <div style="width: 350px; float: right; margin-right: 20px; margin-top: 15px; background-color: #fff0b5; border: 4px solid #FFF; padding: 5px; font-size: 10px;">
  1743.                                                 <?php echo $wpcx_value['desc']; ?>
  1744.                                         </div>
  1745.                                  <?php break;
  1746.                    
  1747.                                 case "checkbox": ?>
  1748.                                         <div style="margin-top:15px; padding:0; float: left; clear: both;">
  1749.                                                 <?php echo $wpcx_value['name']; ?><br/>
  1750.                                                 <?php if(get_option($wpcx_value['id'])){ $wpcx_checked = "checked=\"checked\""; }else{ $wpcx_checked = "";} ?>
  1751.                                                 <input type="checkbox" name="<?php echo $wpcx_value['id']; ?>" id="<?php echo $wpcx_value['id']; ?>" value="true" <?php echo $wpcx_checked; ?> />
  1752.                                         </div>
  1753.                                         <div style="width: 350px; float: right; margin-right: 20px; margin-top: 15px; background-color: #fff0b5; border: 4px solid #FFF; padding: 5px; font-size: 10px;">
  1754.                                                 <?php echo $wpcx_value['desc']; ?>
  1755.                                          </div>
  1756.                             <?php break;
  1757.                         }
  1758.                 }
  1759.                
  1760.         ?>
  1761.        
  1762.                 <div class="container" style="clear: both; background-color: #e8e8e8; border: 1px solid #CCC; padding: 10px; font-size: 11px; width: 650px; margin: 10px; float: left; color: #3b3b3b;">
  1763.                         <p class="submit" style="float: left; margin-right: 20px;">
  1764.                                 <input name="save" type="submit" value="Save changes" />
  1765.                                 <input type="hidden" name="action" value="save" />
  1766.                         </p>
  1767.                         <?php wp_nonce_field('wpcx_save_theme_options','wpcx_options_nonce'); ?>
  1768.                 </form>
  1769.                 <form method="post">
  1770.                         <p class="submit">
  1771.                                 <input name="reset" type="submit" value="Reset" />
  1772.                                 <input type="hidden" name="action" value="reset" />
  1773.                         </p>
  1774.                 </form>
  1775.         </div>
  1776.        
  1777.         <?php
  1778.  
  1779. }
  1780.  
  1781. add_action('admin_menu', 'wpcx_add_admin');
  1782.  
  1783. ?><?php
  1784.  
  1785. function bgmpShortcodeCalled()
  1786. {
  1787.         global $post;
  1788.  
  1789.         $shortcodePageSlugs = array(
  1790.                 'home'
  1791.         );
  1792.  
  1793.         if( $post )
  1794.                 if( in_array( $post->post_name, $shortcodePageSlugs ) )
  1795.                         add_filter( 'bgmp_map-shortcode-called', '__return_true' );
  1796. }
  1797. add_action( 'wp', 'bgmpShortcodeCalled' );
  1798.  
  1799.  
  1800. $wpcx_cxOptions = get_option('cxOptions');
  1801.  
  1802. // Set Content Width
  1803.  
  1804. $content_width = 600;
  1805.  
  1806. //Load Styles
  1807.  
  1808. add_action('wp_print_styles', 'wpcx_add_my_stylesheet');
  1809.  
  1810. function wpcx_add_my_stylesheet() {
  1811.        
  1812.         if ( !is_admin() ) {
  1813.                 global $wpcx_cxOptions;
  1814.                
  1815.                 if(!empty($wpcx_cxOptions['colorpicker'])) {
  1816.                         $wpcx_colour = $wpcx_cxOptions['colorpicker'];
  1817.                 } else {
  1818.                         $wpcx_colour = false;
  1819.                 }
  1820.                
  1821.                 $wpcx_main_style = get_template_directory_uri() . '/style.css';
  1822.                 wp_register_style('mainStyle', $wpcx_main_style);
  1823.                 wp_enqueue_style('mainStyle');
  1824.                
  1825.                 if($wpcx_colour) {
  1826.                         $wpcx_sub_style = get_template_directory_uri() . '/style.php?color=' . $wpcx_colour;
  1827.                 } else {
  1828.                         $wpcx_sub_style = get_template_directory_uri() . '/style.php';
  1829.                 }
  1830.                 wp_register_style('wpcx_sub_style', $wpcx_sub_style);
  1831.                 wp_enqueue_style('wpcx_sub_style');
  1832.         }
  1833.        
  1834. }
  1835.  
  1836. add_action('admin_init', 'wpcx_add_to_admin_style');
  1837.  
  1838. function wpcx_add_to_admin_style() {
  1839.        
  1840.         $wpcx_admin_style = get_template_directory_uri() . '/admin.css';
  1841.         wp_register_style('wpcx_admin_style', $wpcx_admin_style);
  1842.         wp_enqueue_style('wpcx_admin_style');
  1843.        
  1844. }
  1845.  
  1846. function wpcx_add_margin_header() {
  1847.        
  1848.         global $wpcx_cxOptions;
  1849.                
  1850.         if(!empty($wpcx_cxOptions["logo_margin"])) {
  1851.  
  1852.                 echo "<style type='text/css'>#header { margin-top: " . $wpcx_cxOptions["logo_margin"] . "px;}</style>";
  1853.  
  1854.         }
  1855.        
  1856. }
  1857.  
  1858. add_action('wp_head', 'wpcx_add_margin_header');
  1859.  
  1860. //Load JS
  1861.  
  1862. add_action('init', 'wpcx_add_my_scripts');
  1863.  
  1864. function wpcx_add_my_scripts() {
  1865.        
  1866.         if ( !is_admin() ) {
  1867.            
  1868.                 wp_register_script('wpcx_jquery.cycle', get_template_directory_uri() . '/scripts/jquery.cycle.all.js', array('jquery'), '1.0' );
  1869.                 wp_enqueue_script('wpcx_jquery.cycle');
  1870.                 wp_register_script('wpcx_jquery.superfish', get_template_directory_uri() . '/scripts/jquery.superfish.js', array('jquery'), '1.0' );
  1871.                 wp_enqueue_script('wpcx_jquery.superfish');
  1872.                 wp_register_script('wpcx_jquery.fredsel', get_template_directory_uri() . '/scripts/jquery.carouFredSel-2.3.1.js', array('jquery'), '1.0' );
  1873.                 wp_enqueue_script('wpcx_jquery.fredsel');
  1874.                 wp_register_script('wpcx_jquery.fancybox', get_template_directory_uri() . '/scripts/jquery.fancybox-1.3.4.pack.js', array('jquery'), '1.0' );
  1875.                 wp_enqueue_script('wpcx_jquery.fancybox');
  1876.                 wp_register_script('wpcx_custom', get_template_directory_uri() . '/scripts/custom.js', array('jquery'), '1.0' );
  1877.                 wp_enqueue_script('wpcx_custom');
  1878.            
  1879.         } else {
  1880.            
  1881.                 wp_register_script('wpcx_jquery.picker', get_template_directory_uri() . '/scripts/jquery.picker.js', array('jquery'), '1.0' );
  1882.                 wp_enqueue_script('wpcx_jquery.picker');
  1883.                 wp_register_script('wpcx_admin_custom', get_template_directory_uri() . '/scripts/admin_custom.js', array('jquery'), '1.0' );
  1884.                 wp_enqueue_script('wpcx_admin_custom');
  1885.            
  1886.         }
  1887. }
  1888.  
  1889. // Custom Logo Support
  1890.  
  1891. define( 'HEADER_IMAGE', '%s/images/logo.png' );
  1892.  
  1893. define( 'HEADER_IMAGE_WIDTH', apply_filters( '', 520 ) );
  1894.  
  1895. define( 'HEADER_IMAGE_HEIGHT', apply_filters( '', 155 ) );
  1896.  
  1897. define( 'HEADER_TEXTCOLOR', '' );
  1898.  
  1899. define( 'NO_HEADER_TEXT', true );
  1900.  
  1901. add_custom_image_header( '', 'wpcx_admin_header_style' );
  1902.  
  1903. //Add custom post type "Portfolio"
  1904.  
  1905. function wpcx_post_type_myportfolio() {
  1906.        
  1907. register_post_type(
  1908.         'myportfolio',
  1909.         array('label' => 'Portfolio',
  1910.                 'singular_label' => 'Portfolio',
  1911.                 'public' => true,
  1912.                 'show_ui' => true,
  1913.                 'capability_type' => 'post',
  1914.                 'hierarchical' => false,
  1915.                 'rewrite' => array("slug" => "portfolio-item", "with_front" => false),
  1916.                 'supports' => array('title','editor','custom-fields','revisions','thumbnail'),
  1917.                 'menu_position' => 4
  1918.         )
  1919. );
  1920.         register_taxonomy( 'portfolio', 'myportfolio', array( 'hierarchical' => true, 'label' => 'Portfolio Categories' ) );
  1921.        
  1922. }
  1923.  
  1924. add_action('init','wpcx_post_type_myportfolio');
  1925.  
  1926. if (!function_exists( 'wpcx_admin_header_style' )) {
  1927.        
  1928.         function wpcx_admin_header_style() { ?>
  1929.  
  1930.                 <style type="text/css">
  1931.                
  1932.                 #headimg {
  1933.                         height: <?php echo HEADER_IMAGE_HEIGHT; ?>px;
  1934.                         width: <?php echo HEADER_IMAGE_WIDTH; ?>px;
  1935.                 }
  1936.                
  1937.                 #headimg h1, #headimg #desc {
  1938.                         display: none;
  1939.                 }
  1940.                
  1941.                 </style>
  1942.         <?php }
  1943. }
  1944.  
  1945. //WP 3.0 Menu
  1946.  
  1947. add_action('init', 'wpcx_register_custom_menu');
  1948.  
  1949. function wpcx_register_custom_menu() {
  1950.         register_nav_menu('footer_menu', 'Footer Menu');
  1951.         register_nav_menu('nav_menu', 'Navigation Menu');
  1952. }
  1953.  
  1954. //Remove wp_nav wrapping
  1955.  
  1956. function wpcx_my_nav_unlister( $menu ){
  1957.         return preg_replace( array( '#^<ul[^>]*>#', '#</ul>$#' ), '', $menu );
  1958. }
  1959.  
  1960. add_filter( 'wp_nav_menu', 'wpcx_my_nav_unlister' );
  1961.  
  1962. // Fallback Nav Menus
  1963.  
  1964. function wpcx_default_menu() {
  1965.        
  1966.         echo "<li><a href='" . home_url() . "/'>Home</a></li>";
  1967.  
  1968. }
  1969.  
  1970. // Cut some text
  1971.  
  1972. function wpcx_cut_text($text, $chars, $points = "...") {
  1973.         $length = strlen($text);
  1974.         if($length <= $chars) {
  1975.                 return $text;
  1976.         } else {
  1977.                 return substr($text, 0, $chars)." ".$points;
  1978.         }
  1979. }
  1980.  
  1981. // Get WP Generated thumb
  1982.  
  1983. function wpcx_get_wp_generated_thumb($position) {
  1984.         global $post_id;
  1985.         $thumb = get_the_post_thumbnail($post_id, $position);
  1986.         $thumb = explode("\"", $thumb);
  1987.         if(!empty($thumb[5])) {
  1988.                 return $thumb[5];
  1989.         }
  1990. }
  1991.  
  1992. if (function_exists('add_image_size')) {
  1993.         add_image_size( 'slideshow', 480, 210, true );
  1994.         add_image_size( 'slideshow_thumb', 100, 75, true );
  1995.         add_image_size( 'reference', 250, 130, true );
  1996.         add_image_size( 'feat_thumb', 295, 150, true );
  1997. }
  1998.  
  1999. // Styling & Script Functions
  2000.  
  2001. function wpcx_script() {
  2002.        
  2003.         global $wpcx_cxOptions;
  2004.        
  2005.         if(!empty($wpcx_cxOptions["slide_effect"])) {
  2006.                
  2007.                 $wpcx_slide_effect = $wpcx_cxOptions["slide_effect"];
  2008.                
  2009.         } else {
  2010.                
  2011.                 $wpcx_slide_effect = "scrollRight";
  2012.                
  2013.         }
  2014.        
  2015.         if(!empty($wpcx_cxOptions["slide_speed"])) {
  2016.                
  2017.                 $wpcx_slide_speed = $wpcx_cxOptions["slide_speed"];
  2018.                
  2019.         } else {
  2020.                
  2021.                 $wpcx_slide_speed = 500;
  2022.                
  2023.         }
  2024.        
  2025.         if(!empty($wpcx_cxOptions["slide_duration"])) {
  2026.                
  2027.                 $wpcx_slide_duration = $wpcx_cxOptions["slide_duration"];
  2028.                
  2029.         } else {
  2030.                
  2031.                 $wpcx_slide_duration = 3000;
  2032.                
  2033.         }
  2034.        
  2035.        
  2036.        
  2037.         $wpcx_script = '<script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>
  2038.         <script type="text/javascript">
  2039.                         jQuery(document).ready(function($) {
  2040.                                 jQuery("ul#slideshow").cycle({
  2041.                                         fx:             "'.$wpcx_slide_effect.'",
  2042.                                         speed:          '.$wpcx_slide_speed.',
  2043.                                         timeout:        '.$wpcx_slide_duration.',
  2044.                                         pager:          "ul#slide_navigation",
  2045.                         pagerAnchorBuilder: function(idx, slide) {
  2046.                             // return selector string for existing anchor
  2047.                             return "#slide_navigation li:eq(" + idx + ") a";
  2048.                         }
  2049.                 });
  2050.        
  2051.         });
  2052.  
  2053.         </script>';
  2054.        
  2055.         echo $wpcx_script;
  2056.        
  2057. }
  2058.  
  2059. add_action('wp_head', 'wpcx_script');
  2060.  
  2061. function wpcx_style() {
  2062.        
  2063.         $wpcx_style = "";
  2064.        
  2065.         global $wpcx_cxOptions;
  2066.        
  2067.         if(!empty($wpcx_cxOptions["logo_size"])) {
  2068.                
  2069.                 $wpcx_logo_size = $wpcx_cxOptions["logo_size"];
  2070.                
  2071.                 $style = '<style type="text/css">
  2072.                 #logoname a {
  2073.                 font-size: '.$wpcx_logo_size.'px !important;
  2074.                 }
  2075.                 </style>
  2076.                 ';
  2077.                
  2078.         }
  2079.  
  2080.         if(empty($wpcx_cxOptions["logo_file"])) {
  2081.                
  2082.                
  2083.                 $wpcx_style .= '<style type="text/css">
  2084.                 #logoname {
  2085.                 margin-top: 12px;
  2086.                 }
  2087.                 </style>
  2088.                 ';
  2089.  
  2090.         }
  2091.        
  2092.         if(!empty($wpcx_style)) {
  2093.                
  2094.                 echo $wpcx_style;
  2095.        
  2096.         }
  2097.        
  2098. }
  2099.  
  2100. add_action('wp_head', 'wpcx_style');
  2101.  
  2102. function wpcx_list_pages() {
  2103.        
  2104.         echo "<li><a href='".get_bloginfo('url')."'>Home</a>";
  2105.         wp_list_pages('title_li=');
  2106.        
  2107. }
  2108.  
  2109. // Featured Options
  2110.  
  2111. add_action("admin_init", "wpcx_admin_init");
  2112. add_action('save_post', 'wpcx_save_feat');
  2113.  
  2114. function wpcx_admin_init(){
  2115.         add_meta_box("page_feat", "Creativix Options", "wpcx_feat_options", "page", "normal", "high");
  2116.         add_meta_box("post_feat", "Creativix Options", "wpcx_feat_options", "post", "normal", "high");
  2117. }
  2118.  
  2119. function wpcx_feat_options(){
  2120.        
  2121.         global $post;
  2122.         $wpcx_custom = get_post_custom($post->ID);
  2123.         if(!empty($wpcx_custom)) {
  2124.                 if(!empty($wpcx_custom["feat_slideshow"][0])) {
  2125.                         $wpcx_featured = $wpcx_custom["feat_slideshow"][0];
  2126.                 }
  2127.                 if(!empty($wpcx_custom["feat_front"][0])) {
  2128.                         $wpcx_feat_front = $wpcx_custom["feat_front"][0];
  2129.                 }
  2130.         }
  2131. ?>
  2132.         <div class="inside">
  2133.                 <table class="form-table">
  2134.                         <tr>
  2135.                                 <th><label for="featured">Feature in Slideshow?</label></th>
  2136.                                 <td><input type="checkbox" name="featured" value="1" <?php if(isset($wpcx_featured) && $wpcx_featured == 1) { echo "checked='checked'";} ?></td>
  2137.                         </tr>
  2138.                         <tr>
  2139.                                 <th><label for="featured">Feature on frontpage?</label></th>
  2140.                                 <td><input type="checkbox" name="feat_front" value="1" <?php if(isset($wpcx_feat_front) && $wpcx_feat_front == 1) { echo "checked='checked'";} ?></td>
  2141.                         </tr>
  2142.                 </table>
  2143.         </div>
  2144. <?php
  2145. }
  2146.  
  2147. function wpcx_save_feat(){
  2148.        
  2149.         global $post;
  2150.        
  2151.         if($post->post_type == "post" OR $post->post_type == "page") {
  2152.        
  2153.                 if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE )
  2154.                 return $post_id;
  2155.                
  2156.                
  2157.                 if(isset($_POST["featured"])) {
  2158.                        
  2159.                         update_post_meta($post->ID, "feat_slideshow", $_POST["featured"]);
  2160.                        
  2161.                 } else {
  2162.                        
  2163.                         delete_post_meta($post->ID, "feat_slideshow", '');
  2164.                        
  2165.                 }
  2166.                
  2167.                 if(isset($_POST["feat_front"])) {
  2168.                        
  2169.                         update_post_meta($post->ID, "feat_front", $_POST["feat_front"]);
  2170.                        
  2171.                 } else {
  2172.                        
  2173.                         delete_post_meta($post->ID, "feat_front", '');
  2174.                        
  2175.                 }
  2176.        
  2177.         }
  2178.        
  2179. }
  2180.  
  2181.  
  2182. //Check for Post Thumbnail Support
  2183.  
  2184. if ( function_exists( 'add_theme_support' ) )
  2185. add_theme_support( 'post-thumbnails' );
  2186.  
  2187. // Register Sidebar
  2188.  
  2189. if ( function_exists('register_sidebar') )
  2190.     register_sidebar();
  2191.  
  2192. // Add RSS
  2193.  
  2194. add_theme_support('automatic-feed-links');
  2195.  
  2196. // Custom BG
  2197.  
  2198. add_custom_background();
  2199.  
  2200. // Editor Style
  2201.  
  2202. add_editor_style();
  2203.  
  2204. //Loading Theme Options Framework
  2205.  
  2206. $wpcx_themename = "WP-Creativix";
  2207. $wpcx_shortname = "Creativix";
  2208.  
  2209. $wpcx_options = array (
  2210.        
  2211. array( "type" => "open",
  2212. "title" => "Frontpage Settings"
  2213. ),
  2214.  
  2215. array( "name" => "Activate Slideshow on Frontpage?",
  2216.        "desc" => "Decide if you want to show the big Slideshow on Frontpage. By default the Slideshow will be shown.",
  2217.        "id" => "slide_show",
  2218.        "type" => "selectnormal",
  2219.        "options" => array("yes", "no"),
  2220.        "std" => "yes"),
  2221.  
  2222. array( "name" => "Limit Posts/Pages in Slideshow",
  2223.        "desc" => "Set maximum amount of posts/pages to be shown in the slideshow. Leave empty if you don't want to limit them.",
  2224.        "id" => "slide_max",
  2225.        "type" => "text",
  2226.        "std" => ""),
  2227.  
  2228. array( "name" => "Sort Posts/Pages in Slideshow",
  2229.        "desc" => "Choose how you want to sort your posts/pages in the Slideshow. Default sort order is by date",
  2230.        "id" => "slide_sort",
  2231.        "type" => "selectnormal",
  2232.        "options" => array("post_date", "rand", "title"),
  2233.        "std" => "post_date"),
  2234.  
  2235. array( "name" => "Order Posts/Pages in Slideshow",
  2236.        "desc" => "Choose how you want to order your posts/pages in the Slideshow. Default order is DESC",
  2237.        "id" => "slide_order",
  2238.        "type" => "selectnormal",
  2239.        "options" => array("DESC", "ASC"),
  2240.        "std" => "DESC"),
  2241.  
  2242. array( "name" => "Choose Sliding Effect",
  2243.        "desc" => "Choose an effect that will be applied for the Slideshow. Defaul ist scrollRight.",
  2244.        "id" => "slide_effect",
  2245.        "type" => "selectnormal",
  2246.        "options" => array("scrollRight", "fade", 'scrollUp', 'scrollDown', 'blindZ', 'fadeZoom'),
  2247.        "std" => "scrollRight"),
  2248.  
  2249. array( "name" => "Slideshow Transition Speed",
  2250.        "desc" => "Set the Speed for the slideshow's transition. Default ist set to 500 (ms)",
  2251.        "id" => "slide_speed",
  2252.        "type" => "text",
  2253.        "std" => "500"),
  2254.  
  2255. array( "name" => "Slideshow Duration",
  2256.        "desc" => "Set duration for each single Slide Item. Default is set to 3000 (ms)",
  2257.        "id" => "slide_duration",
  2258.        "type" => "text",
  2259.        "std" => "3000"),
  2260.  
  2261. array( "name" => "Sort Posts/Pages for Featured Posts on Frontage",
  2262.        "desc" => "Choose how you want to sort your posts/pages in the Featured Area on Frontage. Default sort order is by date",
  2263.        "id" => "featured_sort",
  2264.        "type" => "selectnormal",
  2265.        "options" => array("post_date", "rand", "title"),
  2266.        "std" => "post_date"),
  2267.  
  2268. array( "name" => "Order Posts/Pages for Featured Posts on Frontpage",
  2269.        "desc" => "Choose how you want to order your posts/pages in the Featured Area. Default order is DESC",
  2270.        "id" => "featured_order",
  2271.        "type" => "selectnormal",
  2272.        "options" => array("DESC", "ASC"),
  2273.        "std" => "DESC"),
  2274.  
  2275. array( "name" => "Sort Posts for Latest Articles",
  2276.        "desc" => "Choose how you want to sort your latest Articles displayed next to featured Articles. Default sort order is by date",
  2277.        "id" => "articles_sort",
  2278.        "type" => "selectnormal",
  2279.        "options" => array("date", "rand", "title"),
  2280.        "std" => "date"),
  2281.  
  2282. array( "name" => "Order Posts for Latest Articles",
  2283.        "desc" => "Choose how you want to order your latest Articles displayed next to featured Articles. Default order is DESC",
  2284.        "id" => "articles_order",
  2285.        "type" => "selectnormal",
  2286.        "options" => array("DESC", "ASC"),
  2287.        "std" => "DESC"),
  2288.  
  2289. array("type" => "close"),
  2290.  
  2291. array( "type" => "open",
  2292.         "title" => "Styling Settings"
  2293.         ),
  2294.  
  2295. array( "name" => "Logo Font Size",
  2296.        "desc" => "Choose a font size for the Logo. Default font size is set to 26px.",
  2297.        "id" => "logo_size",
  2298.        "type" => "text",
  2299.        "std" => "26"),
  2300.  
  2301. array( "name" => "Logo Text",
  2302.        "desc" => "Choose text for the logo. Leave this empty to use your Wordpress Blog Title instead.",
  2303.        "id" => "logo_name",
  2304.        "type" => "text",
  2305.        "std" => ""),
  2306.  
  2307. array( "name" => "Logo/Nav Margin",
  2308.        "desc" => "Choose how many space should be between Social Menu and Navigation/Logo in px.",
  2309.        "id" => "logo_margin",
  2310.        "type" => "text",
  2311.        "std" => ""),
  2312.  
  2313. array( "name" => "Logo Upload",
  2314.        "desc" => "Upload your own Logo. The Logo will not be cropped/resized. You must apply correct width/height before uploading. (Folder wp-creativix/images/logos/ must be writeable)",
  2315.        "id" => "logo_file",
  2316.        "type" => "upload",
  2317.        "std" => ""),
  2318.  
  2319. array( "name" => "Choose an highlight Colour",
  2320.        "desc" => "Click on the input field and choose a highlight colour with the help of the colour-picker.",
  2321.        "id" => "colorpicker",
  2322.        "type" => "text",
  2323.        "std" => "939393"),
  2324.  
  2325. array("type" => "close"),
  2326.  
  2327. array( "type" => "open",
  2328.         "title" => "Social Media Settings"
  2329.         ),
  2330.  
  2331. array( "name" => "Facebook Profile URL",
  2332.        "desc" => "If you want to show the icon, enter the URL (http://..) that points to your Facebook profile. (Leave empty to not show the icon)",
  2333.        "id" => "social_facebook",
  2334.        "type" => "text",
  2335.        "std" => ""),
  2336.  
  2337. array( "name" => "Linkedin Profile ID",
  2338.        "desc" => "Insert your Linkedin Profile ID to show the Linkedin Icon in the Header. (Leave empty to not show the icon)",
  2339.        "id" => "social_linkedin",
  2340.        "type" => "text",
  2341.        "std" => ""),
  2342.  
  2343. array( "name" => "Twitter Username",
  2344.        "desc" => "Insert your Twitter Username to show the Twitter Icon in the Header. (Leave empty to not show the icon)",
  2345.        "id" => "social_twitter",
  2346.        "type" => "text",
  2347.        "std" => ""),
  2348.  
  2349. array( "name" => "Show RSS Icon in Header?",
  2350.        "desc" => "Choose if you want to display the RSS Icon in the Header. Default is set to yes.",
  2351.        "id" => "social_rss",
  2352.        "type" => "selectnormal",
  2353.        "options" => array("yes", "no"),
  2354.        "std" => "yes"),
  2355.  
  2356. array( "name" => "Let Users like posts on Facebook",
  2357.        "desc" => "Choose if you want to display the facebook-like-button next to your Post. Default is set to yes.",
  2358.        "id" => "social_fb_like",
  2359.        "type" => "selectnormal",
  2360.        "options" => array("yes", "no"),
  2361.        "std" => "yes"),
  2362.  
  2363. array( "name" => "Let Users +1 your Posts",
  2364.        "desc" => "Choose if you want to display the Google +1 Button next to your Post. Default is set to yes.",
  2365.        "id" => "social_google_like",
  2366.        "type" => "selectnormal",
  2367.        "options" => array("yes", "no"),
  2368.        "std" => "yes"),
  2369.  
  2370. array("type" => "close"),
  2371.  
  2372. array( "type" => "open",
  2373.         "title" => "Portfolio Settings"
  2374.         ),
  2375.  
  2376. array( "name" => "Sort Portfolio Items by",
  2377.        "desc" => "Choose how you want to sort your Portfolio items on your Portfolio Page. Default sort order is by date",
  2378.        "id" => "portfolio_sort",
  2379.        "type" => "selectnormal",
  2380.        "options" => array("date", "rand", "title"),
  2381.        "std" => "date"),
  2382.  
  2383. array( "name" => "Order Portfolio Items",
  2384.        "desc" => "Choose how you want to order your Portfolio items on your Portfolio Page. Default order is DESC",
  2385.        "id" => "portfolio_order",
  2386.        "type" => "selectnormal",
  2387.        "options" => array("DESC", "ASC"),
  2388.        "std" => "DESC"),
  2389.  
  2390. array( "name" => "Items per Page?",
  2391.        "desc" => "How many Portfolio Items would you like to display per Page? Default is set to 9",
  2392.        "id" => "portfolio_page",
  2393.        "type" => "text",
  2394.        "std" => "9"),
  2395.  
  2396. array("type" => "close"),
  2397.  
  2398. array( "type" => "open",
  2399.         "title" => "Blog Settings"
  2400.         ),
  2401.  
  2402. array( "name" => "Sort Blog Items by",
  2403.        "desc" => "Choose how you want to sort your Blog items on your Blog Page. Default sort order is by date",
  2404.        "id" => "blog_sort",
  2405.        "type" => "selectnormal",
  2406.        "options" => array("date", "rand", "title"),
  2407.        "std" => "date"),
  2408.  
  2409. array( "name" => "Order Blog Items",
  2410.        "desc" => "Choose how you want to order your Blog items on your Blog Page. Default order is DESC",
  2411.        "id" => "blog_order",
  2412.        "type" => "selectnormal",
  2413.        "options" => array("DESC", "ASC"),
  2414.        "std" => "DESC"),
  2415.  
  2416. array( "name" => "Items per Page?",
  2417.        "desc" => "How many Blog Items would you like to display per Page? Default is set to 10",
  2418.        "id" => "blog_page",
  2419.        "type" => "text",
  2420.        "std" => "10"),
  2421.  
  2422. array("type" => "close")
  2423.  
  2424. );
  2425.  
  2426. // create the Options page on the admin side
  2427.  
  2428. function wpcx_add_admin() {
  2429.  
  2430.     global $wpcx_themename, $wpcx_shortname, $wpcx_options;
  2431.  
  2432.         // Saving and Updating the options
  2433.        
  2434.         if (!empty($_GET['page']) && $_GET['page'] == basename(__FILE__) && !empty($_POST) && check_admin_referer('wpcx_save_theme_options','wpcx_options_nonce')) {
  2435.                
  2436.                 if (!empty($_REQUEST['action']) && 'save' == $_REQUEST['action']) {
  2437.                        
  2438.                         $wpcx_cxOptions = array();
  2439.                        
  2440.                         // print_r($_REQUEST);
  2441.                        
  2442.                         foreach ($wpcx_options as $wpcx_value) {
  2443.                                
  2444.                                 if (!empty($wpcx_value['id'])) {
  2445.                                        
  2446.                                         if(isset($_REQUEST[$wpcx_value['id']])) {
  2447.                                        
  2448.                                                 $wpcx_cxOptions[$wpcx_value['id']] = esc_attr($_REQUEST[ $wpcx_value['id'] ]);
  2449.                                                
  2450.                                                 if(strpos($wpcx_cxOptions[$wpcx_value['id']], "http") !== false) {
  2451.                                                        
  2452.                                                         $wpcx_cxOptions[$wpcx_value['id']] = esc_url($_REQUEST[ $wpcx_value['id'] ]);
  2453.                                                        
  2454.                                                 }
  2455.                                        
  2456.                                         }
  2457.                                 }
  2458.                                
  2459.                         }
  2460.                        
  2461.                         // Logo Upload
  2462.                        
  2463.                         if(!empty($_FILES["logo_file"])) {
  2464.                        
  2465.                                 // Upload Logo
  2466.                                
  2467.                                 $wpcx_dir = TEMPLATEPATH . "/images/logos/";
  2468.                                
  2469.                                 if (is_writable($wpcx_dir)) {
  2470.                                        
  2471.                                         if ((($_FILES["logo_file"]["type"] == "image/gif") || ($_FILES["logo_file"]["type"] == "image/jpeg") || ($_FILES["logo_file"]["type"] == "image/png") || ($_FILES["logo_file"]["type"] == "image/pjpeg")) && ($_FILES["logo_file"]["size"] < 1048576)) {
  2472.                                                
  2473.                                                 if ($_FILES["logo_file"]["error"] > 0){
  2474.                                                         echo "Return Code: " . $_FILES["logo_file"]["error"] . "<br />";
  2475.                                                 } else {
  2476.                                                         $_FILES["logo_file"]["name"] = str_replace(' ', '_' , $_FILES["logo_file"]["name"]);
  2477.                                                         if (file_exists($wpcx_dir . $_FILES["logo_file"]["name"])) {
  2478.                                                                 echo $_FILES["logo_file"]["name"] . " already exists. ";
  2479.                                                         } else {
  2480.                                                                 switch($_FILES["logo_file"]["type"]) {
  2481.                                                                         case "image/jpeg" : $wpcx_end = ".jpg";
  2482.                                                                         break;
  2483.                                                                         case "image/png" : $wpcx_end = ".png";
  2484.                                                                         break;
  2485.                                                                         case "image/gif" : $wpcx_end = ".gif";
  2486.                                                                         break;
  2487.                                                                 }
  2488.                                                                 $wpcx_newname = time().$wpcx_end;
  2489.                                                                
  2490.                                                                 if(move_uploaded_file($_FILES["logo_file"]["tmp_name"], $wpcx_dir . $wpcx_newname)) {
  2491.                                                                        
  2492.                                                                         $wpcx_cxOptions['logo_file'] = $wpcx_newname;
  2493.                                                                        
  2494.                                                                 }
  2495.                                                                
  2496.                                                         }
  2497.                                                 }
  2498.                                         }
  2499.                                 }
  2500.                        
  2501.                         }
  2502.                        
  2503.                         if(!empty($_REQUEST['del_pic'])) {
  2504.                                
  2505.                                 $wpcx_cxOptions['logo_file'] = "";
  2506.                                
  2507.                         }
  2508.                        
  2509.                         update_option('cxOptions', $wpcx_cxOptions);
  2510.                
  2511.                         if (!empty($wpcx_value['id']) && isset($_REQUEST[ $wpcx_value['id']])) {
  2512.                                
  2513.                                 update_option('cxOptions', $wpcx_cxOptions);
  2514.                                
  2515.                         } elseif(!empty($wpcx_value['id'])) {
  2516.                                
  2517.                                 delete_option( $wpcx_value['id'] );
  2518.                                
  2519.                         }
  2520.                        
  2521.                         header("Location: themes.php?page=functions.php&saved=true");
  2522.                        
  2523.                 } elseif(!empty($_REQUEST['action']) && 'reset' == $_REQUEST['action']) {
  2524.                        
  2525.                         delete_option('cxOptions');
  2526.                        
  2527.                         header("Location: themes.php?page=functions.php&reset=true");
  2528.                        
  2529.                 }                              
  2530.                        
  2531. }
  2532.                
  2533.  
  2534.     // Add Options page to the admin menu
  2535.    
  2536.     add_theme_page($wpcx_themename." Options", "$wpcx_themename Options", 'edit_theme_options', basename(__FILE__), 'wpcx_admin');
  2537.    
  2538. }
  2539.  
  2540. function wpcx_admin() {
  2541.  
  2542.         global $wpcx_themename, $wpcx_shortname, $wpcx_options;
  2543.    
  2544.         ?>
  2545.        
  2546.         <div class="wrap">
  2547.                 <div style="float: left; margin-top: 50px;">
  2548.                         <h1><img src="<?php echo get_template_directory_uri();?>/images/logo.gif" /></h1>
  2549.                 </div>
  2550.                
  2551.                 <div style="float: left; margin-left: 150px;">
  2552.                         <form action="https://www.paypal.com/cgi-bin/webscr" method="post">
  2553.                                 <input type="hidden" name="cmd" value="_donations">
  2554.                                 <input type="hidden" name="business" value="dennis.nissle@iwebix.de">
  2555.                                 <input type="hidden" name="lc" value="US">
  2556.                                 <input type="hidden" name="item_name" value="WP-Creativix Theme Donation">
  2557.                                 <input type="hidden" name="currency_code" value="USD">
  2558.                                 <input type="hidden" name="bn" value="PP-DonationsBF:btn_donateCC_LG.gif:NonHostedGuest">
  2559.                                 <input type="image" src="<?php echo get_template_directory_uri(); ?>/images/donate.png" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
  2560.                                 <img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
  2561.                         </form>
  2562.                 </div>
  2563.                            
  2564.                 <h2 style="clear: both; margin-left: 5px; margin-bottom: 20px;">WP-Creativix Options Page</h2>
  2565.                
  2566.                 <?php
  2567.                         if ( !empty($_REQUEST['saved']) && $_REQUEST['saved'] ) echo '<div id="message" style="float: left; width: 655px; margin-left: 10px;" class="updated fade"><p><strong>'.$wpcx_themename.' settings saved.</strong></p></div>';
  2568.                         if ( !empty($_REQUEST['reset']) && $_REQUEST['reset'] ) echo '<div id="message" style="float: left; width: 655px; margin-left: 10px;" class="updated fade"><p><strong>'.$wpcx_themename.' settings reset.</strong></p></div>';
  2569.                 ?>
  2570.            
  2571.                 <form method="post" enctype="multipart/form-data">
  2572.                
  2573.                 <?php
  2574.                
  2575.                 //print_r($options);
  2576.                
  2577.                 foreach ($wpcx_options as $wpcx_value) {
  2578.                        
  2579.                         $wpcx_cxOptions = get_option('cxOptions');
  2580.                        
  2581.                         switch ($wpcx_value['type']) {
  2582.                        
  2583.                                 case "open": ?>
  2584.                                         <div class="container" style="clear: both;background-color: #e8e8e8; border: 1px solid #CCC; padding: 10px; font-size: 11px; width: 650px; margin: 10px; float: left; color: #3b3b3b;">
  2585.                                         <h3><?php echo $wpcx_value['title']; ?></h3>
  2586.                                 <?php break;
  2587.              
  2588.                                 case "close": ?>
  2589.                                         </div>
  2590.                                 <?php break;
  2591.              
  2592.                                 case 'text': ?>
  2593.                                         <div style="margin-top:15px; float: left; clear: both;">
  2594.                                                 <?php echo $wpcx_value['name']; ?><br/>
  2595.                                                 <input name="<?php echo $wpcx_value['id']; ?>" id="<?php echo $wpcx_value['id']; ?>" type="<?php echo $wpcx_value['type']; ?>" value="<?php if ( !empty($wpcx_cxOptions[$wpcx_value['id']])) { echo esc_attr($wpcx_cxOptions[$wpcx_value['id']]); } else { echo $wpcx_value['std']; } ?>" />
  2596.                                         </div>
  2597.                                         <div style="width: 350px; float: right; margin-right: 20px; margin-top: 15px; background-color: #fff0b5; border: 4px solid #FFF; padding: 5px; font-size: 10px;">
  2598.                                                 <?php echo $wpcx_value['desc']; ?>
  2599.                                         </div>
  2600.                                 <?php break;
  2601.              
  2602.                                 case 'textarea': ?>
  2603.                                
  2604.                                         <div style="margin-top:15px;padding:0; float: left; clear: both;">
  2605.                                                 <?php echo $wpcx_value['name']; ?><br/>
  2606.                                                 <textarea style="width: 200px; height:70px; font-size: 10px; border: 1px solid #b6b6b6;" name="<?php echo $wpcx_value['id']; ?>" id="<?php echo $wpcx_value['id']; ?>" type="<?php echo $wpcx_value['type']; ?>" cols="" rows=""><?php if ( !empty($wpcx_cxOptions[$wpcx_value['id']])) { echo esc_attr($wpcx_cxOptions[$wpcx_value['id']]); } else { echo $wpcx_value['std']; } ?></textarea>
  2607.                                         </div>
  2608.                                         <div style="width: 350px; float: right; margin-right: 20px; margin-top: 25px; background-color: #fff0b5; border: 4px solid #FFF; padding: 5px; font-size: 10px;">
  2609.                                                 <?php echo $wpcx_value['desc']; ?>
  2610.                                         </div>  
  2611.                                 <?php break;
  2612.                                
  2613.                                 case 'upload': ?>
  2614.                                
  2615.                                         <div style="margin-top:15px;padding:0; float: left; clear: both;">
  2616.                                                 <?php echo $wpcx_value['name']; ?><br/>
  2617.                                                 <input type="file" name="<?php echo $wpcx_value['id'];?>" id="<?php echo $wpcx_value['id'];?>" />
  2618.                                         </div>
  2619.                                         <div style="width: 350px; float: right; margin-right: 20px; margin-top: 25px; background-color: #fff0b5; border: 4px solid #FFF; padding: 5px; font-size: 10px;">
  2620.                                                 <?php echo $wpcx_value['desc']; ?>
  2621.                                         </div>
  2622.                                         <?php if ( !empty($wpcx_cxOptions[$wpcx_value['id']])) {
  2623.                                                 echo "<div class='logo' style='float: left; clear: both;'><img style='float: left; clear: both;' src='".get_template_directory_uri()."/images/logos/".$wpcx_cxOptions[$wpcx_value['id']]."'/><p style='float: left; clear: both;'><input type='checkbox' name='del_pic' value='del' />Delete Logo</p><input type='hidden' name='logo_file' value='".$wpcx_cxOptions[$wpcx_value['id']]."' /></div>";
  2624.                                         }
  2625.                                         ?>
  2626.                                 <?php break;
  2627.              
  2628.                                 case 'selectnormal': ?>
  2629.                                         <div style="margin-top:15px; padding:0; float: left; clear: both;">
  2630.                                                 <?php echo $wpcx_value['name']; ?><br/>
  2631.                                                 <select name="<?php echo $wpcx_value['id']; ?>" id="<?php echo $wpcx_value['id']; ?>"><?php foreach ($wpcx_value['options'] as $wpcx_option) { ?><option<?php if(!empty($wpcx_cxOptions[$wpcx_value['id']]) &&$wpcx_cxOptions[$wpcx_value['id']] == $wpcx_option) { echo ' selected="selected"'; } elseif ($wpcx_option == $wpcx_value['std']) { echo ' selected="selected"'; } ?>><?php echo $wpcx_option; ?></option><?php } ?></select>
  2632.                                         </div>
  2633.                                         <div style="width: 350px; float: right; margin-right: 20px; margin-top: 15px; background-color: #fff0b5; border: 4px solid #FFF; padding: 5px; font-size: 10px;">
  2634.                                                 <?php echo $wpcx_value['desc']; ?>
  2635.                                         </div>
  2636.                                  <?php break;
  2637.                    
  2638.                                 case "checkbox": ?>
  2639.                                         <div style="margin-top:15px; padding:0; float: left; clear: both;">
  2640.                                                 <?php echo $wpcx_value['name']; ?><br/>
  2641.                                                 <?php if(get_option($wpcx_value['id'])){ $wpcx_checked = "checked=\"checked\""; }else{ $wpcx_checked = "";} ?>
  2642.                                                 <input type="checkbox" name="<?php echo $wpcx_value['id']; ?>" id="<?php echo $wpcx_value['id']; ?>" value="true" <?php echo $wpcx_checked; ?> />
  2643.                                         </div>
  2644.                                         <div style="width: 350px; float: right; margin-right: 20px; margin-top: 15px; background-color: #fff0b5; border: 4px solid #FFF; padding: 5px; font-size: 10px;">
  2645.                                                 <?php echo $wpcx_value['desc']; ?>
  2646.                                          </div>
  2647.                             <?php break;
  2648.                         }
  2649.                 }
  2650.                
  2651.         ?>
  2652.        
  2653.                 <div class="container" style="clear: both; background-color: #e8e8e8; border: 1px solid #CCC; padding: 10px; font-size: 11px; width: 650px; margin: 10px; float: left; color: #3b3b3b;">
  2654.                         <p class="submit" style="float: left; margin-right: 20px;">
  2655.                                 <input name="save" type="submit" value="Save changes" />
  2656.                                 <input type="hidden" name="action" value="save" />
  2657.                         </p>
  2658.                         <?php wp_nonce_field('wpcx_save_theme_options','wpcx_options_nonce'); ?>
  2659.                 </form>
  2660.                 <form method="post">
  2661.                         <p class="submit">
  2662.                                 <input name="reset" type="submit" value="Reset" />
  2663.                                 <input type="hidden" name="action" value="reset" />
  2664.                         </p>
  2665.                 </form>
  2666.         </div>
  2667.        
  2668.         <?php
  2669.  
  2670. }
  2671.  
  2672. add_action('admin_menu', 'wpcx_add_admin');
  2673.  
  2674. ?>