SHARE
TWEET

Cube functions

a guest Aug 13th, 2013 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. add_theme_support('post-thumbnails');
  3. add_theme_support('automatic-feed-links');
  4.  
  5. if ( ! isset( $content_width ) ) $content_width = 900;
  6.  
  7. /*Image Sizes*/
  8. add_image_size("magazine_image", 770, 364, true);
  9. add_image_size("related_image", 370, 278, true);
  10. add_image_size("um_thumbnail", 172, 115, true);
  11. add_image_size("um_thumbnail_2", 236, 177, true);
  12. add_image_size("um_thumbnail_3", 370, 278, true);
  13. add_image_size("um_thumbnail_3_variable", 370, 278, false);
  14. add_image_size("featured_slider", 570, 308, true);
  15. add_image_size("slider_image", 285, 214, true);
  16. add_image_size("gallery_image", 720, 540, true);
  17. /*Image Sizes*/
  18.  
  19. /*Lang*/
  20. add_action('after_setup_theme', 'my_theme_setup');
  21. function my_theme_setup(){
  22.     load_theme_textdomain('um_lang', get_template_directory() . '/lang');
  23. }
  24. /*Lang*/
  25.  
  26. /*Include ACF HERE*/
  27. if(!isACFActive()){
  28.     define( 'ACF_LITE' , true );
  29.     include_once('advanced-custom-fields/acf.php' );
  30. }
  31. require_once "includes/custom-fields.php";
  32. /*Include ACF HERE*/
  33.  
  34. /*Register Option Pages*/
  35. if (function_exists("register_options_page")) {
  36.     register_options_page('Main');
  37.     register_options_page('Footer');
  38.     register_options_page('Sidebars');
  39.     register_options_page('Twitter');
  40.     register_options_page('Front-end Submission');
  41.     register_options_page('Branding');
  42. }
  43. /*Register Option Pages*/
  44.  
  45. /*Includes*/
  46. require_once "includes/tgm/plugins.php";
  47. require_once "includes/google-fonts.php";
  48. require_once "shortcodes/shortcodes.php";
  49. require_once "includes/breadcrumb.php";
  50. require_once "includes/save-post.php";
  51. require_once "includes/sidebars.php";
  52. require_once "widgets/widgets.php";
  53. /*Includes*/
  54.  
  55. /*Register New Fields*/
  56. add_action('acf/register_fields', 'register_fields');
  57. function register_fields()
  58. {
  59.     include_once('includes/acf-location-field/acf-location.php');
  60. }
  61. /*Register New Fields*/
  62.  
  63. function my_acf_options_page_settings($options){
  64.     $options['capability'] = 'install_themes';
  65.     return $options;
  66. }
  67. add_filter('acf/options_page/settings', 'my_acf_options_page_settings');
  68.  
  69. /*Globals*/
  70. global $um_submit;
  71. global $um_profile;
  72. global $um_edit;
  73. global $um_new_user_role;
  74. global $um_facebook_app_id;
  75. global $default_post_status;
  76. global $allow_users_to_publish;
  77. add_action("init","init_globals");
  78.  
  79. function init_globals(){
  80.     global $um_submit;
  81.     global $um_profile;
  82.     global $um_edit;
  83.     global $um_new_user_role;
  84.     global $um_facebook_app_id;
  85.     global $default_post_status;
  86.     global $allow_users_to_publish;
  87.     $allow_users_to_publish = get_field("allow_users_to_publish_posts","options") == "Disabled" ? false : true;
  88.     $default_post_status = get_field("default_post_status","options") ? get_field("default_post_status","options") : "draft";
  89.     $um_submit = get_field("submit_permalink_keyword","options") ? get_field("submit_permalink_keyword","options") : "submit";
  90.     $um_profile = get_field("profile_permalink_keyword","options") ? get_field("profile_permalink_keyword","options") : "profile";
  91.     $um_edit = "edit";
  92.     $um_new_user_role = get_field("default_users_role","options") ? get_field("default_users_role","options") :"subscriber";
  93.     if(get_field("allow_users_to_register_and_login_with_facebook","options") == "Disabled"){
  94.         $um_facebook_app_id = "";
  95.     }else{
  96.         $um_facebook_app_id = get_field("facebook_app_id","options");
  97.     }
  98.  
  99. }
  100. /*Globals*/
  101.  
  102. /*Custom Slug Generator*/
  103. function toAscii($str){
  104.     $clean = preg_replace("/[^a-zA-Z0-9\/_|+ -]/", '', $str);
  105.     $clean = strtolower(trim($clean, '-'));
  106.     $clean = preg_replace("/[\/_|+ -]+/", '-', $clean);
  107.     return $clean;
  108. }
  109. /*Custom Slug Generator*/
  110.  
  111. /*Register Menu*/
  112. add_action('init', 'register_my_menus');
  113.  
  114. function register_my_menus()
  115. {
  116.     register_nav_menus(
  117.         array(
  118.             'main_menu' => __('Main Menu', "um-lang"),
  119.             'mobile_menu' => __('Mobile Menu', "um-lang")
  120.         )
  121.     );
  122. }
  123. /*Register Menu*/
  124.  
  125. /*Custom Rewrite Rules*/
  126. add_action( 'init', 'um_add_rewrite_rules' );
  127. function um_add_rewrite_rules(){
  128.     add_rewrite_rule('^'.$GLOBALS["um_profile"].'/edit?','index.php?umeditprofile=1','top');
  129.     add_rewrite_rule('^'.$GLOBALS["um_profile"].'/([^/]*)/?','index.php?umprofile=1&user_slug=$matches[1]','top');
  130.     add_rewrite_rule('^'.$GLOBALS["um_profile"].'/?','index.php?umprofile=1','top');
  131.  
  132.     add_rewrite_rule('^'.$GLOBALS["um_submit"].'/([^/]*)/?','index.php?umsubmit=1&umpostid=$matches[1]','top');
  133.     add_rewrite_rule('^'.$GLOBALS["um_submit"].'/?','index.php?umsubmit=1','top');
  134. }
  135.  
  136. add_filter( 'query_vars', 'wpa5413_query_vars' );
  137. function wpa5413_query_vars( $query_vars )
  138. {
  139.     $query_vars[] = 'list';
  140.     $query_vars[] = 'rowid';
  141.     $query_vars[] = 'umprofile';
  142.     $query_vars[] = 'umsubmit';
  143.     $query_vars[] = 'umeditprofile';
  144.     $query_vars[] = 'user_slug';
  145.     $query_vars[] = 'umpostid';
  146.     return $query_vars;
  147. }
  148.  
  149. add_filter( 'template_redirect', 'wpse36736_template_redirect' );
  150. function wpse36736_template_redirect(){
  151.     global $wp_query;
  152.     if( $wp_query->get( 'umprofile' ) ):
  153.         get_template_part("user","profile");
  154.         exit();
  155.     endif;
  156.     if( $wp_query->get( 'umsubmit' ) ):
  157.         get_template_part("template","submit");
  158.         exit();
  159.     endif;
  160.     if( $wp_query->get( 'umeditprofile' ) ):
  161.         get_template_part("user","edit-profile");
  162.         exit();
  163.     endif;
  164. }
  165. /*Custom Rewrite Rules*/
  166.  
  167. /*views*/
  168. function get_views($set = false){
  169.     global $post;
  170.     $views = get_post_meta($post->ID, "umbrella_post_view", true);
  171.     if($set){
  172.         $views = intval($views) + 1;
  173.         if($views){
  174.             update_post_meta($post->ID, "umbrella_post_view" , $views );
  175.         }else{
  176.             add_post_meta($post->ID, "umbrella_post_view" , 1 );
  177.         }
  178.     }
  179.     return $views ? number_format($views, 0, ' ', ' ') : 0;
  180. }
  181. /*views*/
  182.  
  183. /*Like System*/
  184. add_action('wp_ajax_um_like_post', 'um_like_post');
  185.  
  186. function um_like_post(){
  187.     if(!is_user_logged_in()){
  188.         die("-1");
  189.     }
  190.     $postid = $_POST["to_like"];
  191.     $this_user = wp_get_current_user();
  192.     $post_likes = get_post_meta($postid,"um_post_likes");
  193.     if(is_array($post_likes) && in_array($this_user->ID,$post_likes)){
  194.         delete_post_meta($postid, "um_post_likes" , $this_user->ID);
  195.         echo "removed_like";
  196.     }else{
  197.         add_post_meta($postid,"um_post_likes",$this_user->ID);
  198.         echo "added_like";
  199.     }
  200.  
  201.     /*Update Number of post likes*/
  202.     $post_likes = get_post_meta($postid,"um_post_likes");
  203.  
  204.     $number_of_post_likes = get_post_meta($postid,"um_num_post_likes");
  205.     if($number_of_post_likes){
  206.         update_post_meta($postid,"um_num_post_likes",count($post_likes));
  207.     }else{
  208.         add_post_meta($postid,"um_num_post_likes",count($post_likes));
  209.     }
  210.  
  211.     /*Remove dis-like just in case*/
  212.     delete_post_meta($postid, "um_post_dislikes" , $this_user->ID);
  213.     die;
  214. }
  215.  
  216. add_action('wp_ajax_um_dislike_post', 'um_dislike_post');
  217.  
  218. function um_dislike_post(){
  219.     if(!is_user_logged_in()){
  220.         die("-1");
  221.     }
  222.     $postid = $_POST["to_like"];
  223.     $this_user = wp_get_current_user();
  224.     $post_likes = get_post_meta($postid,"um_post_dislikes");
  225.     if(is_array($post_likes) && in_array($this_user->ID,$post_likes)){
  226.         delete_post_meta($postid, "um_post_dislikes" , $this_user->ID);
  227.         echo "removed_like";
  228.     }else{
  229.         add_post_meta($postid,"um_post_dislikes",$this_user->ID);
  230.         echo "added_like";
  231.     }
  232.     /*Remove Like's just in case*/
  233.     delete_post_meta($postid, "um_post_likes" , $this_user->ID);
  234.     die;
  235. }
  236. /*Like System*/
  237.  
  238. /*Ajax Autocomplete*/
  239. add_action('wp_ajax_nopriv_get_autocomplete', 'um_get_autocomplete');
  240. add_action('wp_ajax_get_autocomplete', 'um_get_autocomplete');
  241.  
  242. function um_get_autocomplete(){
  243.  
  244.     $search = $_REQUEST["um_search"];
  245.     $queried_posts = array();
  246.     $the_query = new WP_Query( array("s"=>$search,"posts_per_page"=>-1,"post_type"=>"post") );
  247.     while ( $the_query->have_posts() ){
  248.         $the_query->the_post();
  249.         array_push($queried_posts,array("permalink"=>get_permalink(),"title"=>get_the_title()));
  250.     }
  251.     echo json_encode($queried_posts);
  252.     die;
  253. }
  254. /*Ajax Autocomplete*/
  255.  
  256. /*Ajax Login*/
  257. add_action('wp_ajax_nopriv_auth_user', 'auth_user');
  258. add_action('wp_ajax_auth_user', 'auth_user');
  259. function auth_user(){
  260.     $user_name = $_POST["um_username"];
  261.     $password = $_POST["um_pass"];
  262.     $auth = wp_authenticate($user_name,$password);
  263.     if(!is_wp_error($auth)){
  264.         wp_signon(array("user_login"=>$user_name,"user_password"=>$password),false);
  265.     }
  266.     echo !is_wp_error($auth);
  267.     die;
  268. }
  269.  
  270. add_action('wp_ajax_nopriv_auth_user_fb', 'auth_user_fb');
  271. add_action('wp_ajax_auth_auth_user_fb', 'auth_user_fb');
  272. function auth_user_fb(){
  273.     $facebook_id = $_POST["facebook_id"];
  274.     $user_fb = get_users(array("meta_key "=>"um_facebook_id","meta_value"=>$facebook_id));
  275.     if(is_wp_error($user_fb) || !count($user_fb)){
  276.         echo "-1";
  277.     }else{
  278.         wp_set_auth_cookie($user_fb[0]->ID);
  279.         echo "1";
  280.     }
  281.     die;
  282. }
  283. /*Ajax Login*/
  284.  
  285. /*Ajax Signup*/
  286. add_action('wp_ajax_nopriv_signup_user', 'signup_user');
  287. add_action('wp_ajax_signup_user', 'signup_user');
  288.  
  289. function signup_user(){
  290.     $user_name = $_POST["um_username"];
  291.     $user_email = $_POST["um_email"];
  292.     $user_facebook_id = "";
  293.     if(isset($_POST["um_facebookid"]) && $_POST["um_facebookid"]){
  294.         $user_facebook_id = $_POST["um_facebookid"];
  295.     }
  296.  
  297.     if(username_exists( $user_name )){
  298.         die("user_exists");
  299.     }elseif(email_exists($user_email)){
  300.         die("email_exists");
  301.     }else{
  302.         $random_password = wp_generate_password( $length=12, $include_standard_special_chars=false );
  303.         $user_id = wp_create_user( $user_name, $random_password, $user_email );
  304.  
  305.         $message = __("Here bellow you can find your credentials","um_lang")."
  306.         Username : {$user_name},
  307.         Password : {$random_password}
  308.         ";
  309.         wp_update_user( array ( 'ID' => $user_id, 'role' => $GLOBALS["um_new_user_role"] ) ) ;
  310.         wp_mail($user_email,site_url().__(" Thank you for your registration","um_lang"),$message);
  311.         wp_signon(array("user_login"=>$user_name,"user_password"=>$random_password),false);
  312.         if($user_facebook_id){
  313.             update_user_meta($user_id,"um_facebook_id",$user_facebook_id);
  314.         }
  315.         echo 1;
  316.     }
  317.  
  318.     die;
  319. }
  320. /*Ajax Signup*/
  321.  
  322. /*Ajax Forgot Password*/
  323. add_action('wp_ajax_nopriv_um_reset_password', 'um_reset_password');
  324. add_action('wp_ajax_um_reset_password', 'um_reset_password');
  325.  
  326. function um_reset_password(){
  327.     $email = $_POST["um_email"];
  328.  
  329.     if(email_exists($email)){
  330.         include "../wp-login.php";
  331.         retrieve_password($email);
  332.     }else{
  333.         echo "-1";
  334.     }
  335.  
  336.     die;
  337. }
  338. /*Ajax Forgot Password*/
  339.  
  340. function group_array($array,$group){
  341.     if(!$array || !is_array($array)){
  342.         return false;
  343.     }
  344.     $tmp_array = array();
  345.     $array_holder = array_merge($array);
  346.     $tool_array = array();
  347.     $group_by = 0;
  348.     foreach($array as $key => $value){
  349.         if($group_by % $group == 0 && $group_by != 0){
  350.             array_push($tmp_array,$tool_array);
  351.             $tool_array = array();
  352.         }
  353.         array_push($tool_array,$value);
  354.         $group_by++;
  355.         array_shift($array_holder);
  356.     }
  357.     foreach($array_holder as $arr){
  358.         if($arr){
  359.             array_push($tool_array,$arr);
  360.         }
  361.     }
  362.     array_push($tmp_array,$tool_array);
  363.     return $tmp_array;
  364. }
  365.  
  366. /*Categories*/
  367. function my_acf_load_field_categories( $field )
  368. {
  369.     // reset choices
  370.     $field['choices'] = array();
  371.     $field['choices'][''] = "---";
  372.  
  373.     // get the textarea value from options page
  374.     $choices = array();
  375.     $choices[""] = "---";
  376.  
  377.     $terms = get_terms("category");
  378.     if($terms){
  379.         foreach($terms as $t){
  380.             $field['choices'][$t->term_id] = $t->name;
  381.         }
  382.     }
  383.     // Important: return the field
  384.     return $field;
  385. }
  386.  
  387. add_action('acf/load_field/key=field_51d198e2f34f0', 'my_acf_load_field_categories');
  388. add_action('acf/load_field/key=field_51d198bef34ee', 'my_acf_load_field_categories');
  389. add_action('acf/load_field/key=field_51d198cdf34ef', 'my_acf_load_field_categories');
  390. add_action('acf/load_field/key=field_51dc00b6cae2c', 'my_acf_load_field_categories');
  391. /*Categories*/
  392.  
  393. /*Default Post Thumbs*/
  394. add_filter( 'post_thumbnail_html', 'my_post_image_html', 10, 3 );
  395.  
  396. function my_post_image_html( $html, $post_id, $post_image_id ) {
  397.     if( '' == $html ){
  398.         $default_img = get_field("default_featured_image","options");
  399.         if($default_img){
  400.             $html = '<img src="'.$default_img["url"].'" />';
  401.         }
  402.     }
  403.     return $html;
  404. }
  405. /*Default Post Thumbs*/
  406.  
  407. /*Get Tweets*/
  408. function um_get_tweets(){
  409.     function my_streaming_callback($data, $length, $metrics) {
  410.         return TRUE;
  411.     }
  412.  
  413.     require 'includes/oAuth/tmhOAuth.php';
  414.     require 'includes/oAuth/tmhUtilities.php';
  415.     $tmhOAuth = new tmhOAuth(array(
  416.         'consumer_key'    => get_field("consumer_key","options"),
  417.         'consumer_secret' => get_field("consumer_secret","options"),
  418.         'user_token'      => get_field("user_token","options"),
  419.         'user_secret'     => get_field("user_secret","options"),
  420.     ));
  421.  
  422.     $method = "https://api.twitter.com/1.1/statuses/user_timeline.json";
  423.     $params = array(
  424.         'screen_name' => get_field("twitter_username","options"),
  425.         'count' => get_field("number_of_tweets","options") ? get_field("number_of_tweets","options") : 30,
  426.         'exclude_replies' => get_field("exclude_replies","options") ? 1 : 0
  427.     );
  428.     $tmhOAuth->request('GET', $method, $params, 'my_streaming_callback');
  429.     echo $tmhOAuth->response['response'];
  430.     die();
  431. }
  432. add_action('wp_ajax_um_get_tweets', 'um_get_tweets');
  433. add_action('wp_ajax_nopriv_um_get_tweets', 'um_get_tweets');
  434. /*Get Tweets*/
  435.  
  436. /*Get Video Embedd*/
  437. function getVideoEmbed($vurl,$height = "100%",$width="100%"){
  438.     $image_url = parse_url($vurl);
  439.     // Test if the link is for youtube
  440.     if($image_url['host'] == 'www.youtube.com' || $image_url['host'] == 'youtube.com'){
  441.         $array = explode("&", $image_url['query']);
  442.         return '<iframe class="youtube" src="http://www.youtube.com/embed/' . substr($array[0], 2) . '?wmode=transparent&enablejsapi=1" width="'.$width.'" height="'.$height.'" frameborder="0" allowfullscreen></iframe>'; // Returns the youtube iframe embed code
  443.         // Test if the link is for the shortened youtube share link
  444.     } else if($image_url['host'] == 'www.youtu.be' || $image_url['host'] == 'youtu.be'){
  445.         $array = ltrim($image_url['path'],'/');
  446.         return '<iframe class="youtube" src="http://www.youtube.com/embed/' . $array . '?wmode=transparent&enablejsapi=1" width="'.$width.'" height="'.$height.'" frameborder="0" allowfullscreen></iframe>'; // Returns the youtube iframe embed code
  447.         // Test if the link is for vimeo
  448.     } else if($image_url['host'] == 'www.vimeo.com' || $image_url['host'] == 'vimeo.com'){
  449.         $hash = substr($image_url['path'], 1);
  450.         return '<iframe class="vimeo" src="http://player.vimeo.com/video/' . $hash . '?title=0&byline=0&portrait=0&api=1" width="'.$width.'" height="'.$height.'" frameborder="0" webkitAllowFullScreen allowfullscreen></iframe>'; // Returns the vimeo iframe embed code
  451.     }
  452. }
  453. /*Get Video Embedd*/
  454.  
  455. /*Rewrite rules in case of some options change*/
  456. function my_acf_update_value_flush($old)
  457. {
  458.     global $wp_rewrite;
  459.     $wp_rewrite->flush_rules();
  460. }
  461. add_action("update_option_options_profile_permalink_keyword","my_acf_update_value_flush");
  462. add_action("update_option_options_submit_permalink_keyword","my_acf_update_value_flush");
  463. /*Rewrite rules in case of some options change*/
  464.  
  465. /*Get Post Statuses*/
  466. function my_acf_load_post_statuses( $field )
  467. {
  468.     // reset choices
  469.     $field['choices'] = array();
  470.  
  471.     // get the textarea value from options page
  472.     $choices = array();
  473.     global $wp_post_statuses;
  474.     $statuses = $wp_post_statuses;
  475.     foreach($statuses as $key=>$status){
  476.         $field['choices'][$key] = $status->label;
  477.     }
  478.     return $field;
  479. }
  480.  
  481. add_action('acf/load_field/key=field_51e50f425e654', 'my_acf_load_post_statuses');
  482. /*Get Post Statuses*/
  483.  
  484. /*Get User Roles*/
  485. function my_acf_load_user_roles( $field )
  486. {
  487.     // reset choices
  488.     $field['choices'] = array();
  489.  
  490.     // get the textarea value from options page
  491.     global $wp_roles;
  492.     foreach($wp_roles->roles as $key => $role){
  493.         $field['choices'][$key] = $role["name"];
  494.     }
  495.     return $field;
  496. }
  497.  
  498. add_action('acf/load_field/key=field_51e50f16a1021', 'my_acf_load_user_roles');
  499. /*Get User Roles*/
  500.  
  501. /*Add Post Thumbnail If it does not exist*/
  502. //add_action( 'post_updated', 'my_project_updated' );
  503.  
  504. function my_project_updated( $post_id ){
  505.     if(!has_post_thumbnail($post_id)){
  506.         $default_img = get_field("default_featured_image","options");
  507.         if($default_img){
  508.             $default_img = $default_img["id"];
  509.             set_post_thumbnail($post_id,$default_img);
  510.         }
  511.     }
  512. }
  513. /*Add Post Thumbnail If it does not exist*/
  514.  
  515. /*New Options Page Import Tool*/
  516. add_action('admin_menu', 'register_my_custom_submenu_page' , 99);
  517.  
  518. function register_my_custom_submenu_page() {
  519.     add_submenu_page( 'acf-options-main', 'Documentation', 'Documentation', 'manage_options', 'admin.php?page=acf-options-documentation', 'my_documentation_menu_callback' );
  520. }
  521.  
  522. function my_documentation_menu_callback(){
  523.     ?>
  524.     <div class="icon32" id="icon-options-general"><br></div>
  525.     <h2><?php _e("Documentation","um_lang"); ?></h2>
  526.     <iframe width="100%" height="800px" src="http://documentation.umbrella.al/cube-documentation/" frameborder="0"></iframe>
  527.     <?php
  528. }
  529.  
  530. function my_custom_submenu_page_callback() {
  531.  
  532.     ?>
  533.     <div class="icon32" id="icon-options-general"><br></div>
  534.     <h2><?php _e("Import Options","um_lang"); ?></h2>
  535.     <form action="admin.php?page=admin.php">
  536.         <input type="hidden" name="page" value="admin.php?page=acf-options-import"/>
  537.         <textarea name="um_import" id="" cols="30" rows="10"></textarea><br/>
  538.         <input type="submit" value="<?php _e("Import","um_lang"); ?>"/>
  539.     </form>
  540.     <?php
  541.  
  542.     if(isset($_GET["um_to_export"])){
  543.         $export_fields = array();
  544.         $not_allowed_fields = array("repeater","image");
  545.         $fields_droups = $GLOBALS['acf_register_field_group'];
  546.         foreach($fields_droups as $field_group){
  547.             $is_in_options = false;
  548.             foreach($field_group["location"] as $location){
  549.                 foreach($location as $lo){
  550.                     if(in_array("options_page",$lo)){
  551.                         $is_in_options = true;
  552.                         break;
  553.                     }
  554.                 }
  555.                 if($is_in_options){
  556.                     break;
  557.                 }
  558.             }
  559.             if($is_in_options){
  560.                 foreach($field_group["fields"] as $field){
  561.                     if(!in_array($field["type"],$not_allowed_fields)){
  562.                         array_push($export_fields,array(
  563.                             "key" => $field["key"],
  564.                             "value" => get_field($field["name"],"options",false)
  565.                         ));
  566.                     }
  567.                 }
  568.             }
  569.         }
  570.         echo json_encode($export_fields);
  571.     }
  572.  
  573.     if(isset($_GET["um_import"])){
  574.         $import_data = $_GET["um_import"];
  575.         if($import_data){
  576.             $import_data = json_decode(stripcslashes($import_data),true);
  577.             if($import_data){
  578.                 foreach($import_data as $data){
  579.                     try{
  580.                         update_field($data["key"],$data["value"],"option");
  581.                     }catch (Exception $err){
  582.  
  583.                     }
  584.                 }
  585.             }
  586.         }
  587.     }
  588. }
  589. /*New Options Page Import Tool*/
  590.  
  591. /*Enqueue CSS and JS*/
  592. add_action( 'wp_enqueue_scripts', 'add_external_stylesheets' );
  593. function add_external_stylesheets(){
  594.     wp_enqueue_style("fancybox", get_template_directory_uri() . "/assets/fancybox/jquery.fancybox-1.3.4.css", false, "1.0");
  595.     wp_enqueue_style("bootstrap", get_template_directory_uri() . "/assets/css/bootstrap.css", false, "1.0");
  596.     wp_enqueue_style("responsive", get_template_directory_uri() . "/assets/css/bootstrap-responsive.css", false, "1.0");
  597.     wp_enqueue_style("font-awesome", get_template_directory_uri() . "/assets/css/font-awesome.min.css", false, "1.0");
  598.     wp_enqueue_style("mediaelementplayer", get_template_directory_uri() . "/assets/mediaelement/mediaelementplayer.min.css", false, "1.0");
  599.     wp_enqueue_style("customScrollbar", get_template_directory_uri() . "/assets/css/jquery.mCustomScrollbar.css", false, "1.0");
  600.     wp_enqueue_style("jqueryui", "http://code.jquery.com/ui/1.9.1/themes/base/jquery-ui.css", false, "1.0");
  601.     wp_enqueue_style("style", get_template_directory_uri() . "/assets/css/style.css", false, "1.0");
  602.     if(get_field("theme_skin","options") == "white"){
  603.         wp_enqueue_style("white_skin", get_template_directory_uri() . "/assets/css/white.css", false, "1.0");
  604.     }
  605.     if(get_field("brand_color","options")){
  606.         wp_enqueue_style("dynamic", get_template_directory_uri() . "/assets/css/dynamic.php?preset=".urlencode(get_field("brand_color","options")), false, "1.0");
  607.     }
  608.     if(get_field("post_views","options") == "Disabled"){
  609.         wp_enqueue_style("disable_views",get_template_directory_uri()."/assets/css/dynamic.php?post_views=true",false);
  610.     }
  611.     $font = get_field("google_fonts","options");
  612.     if($font && $font != "--None--"){
  613.         $font = $GLOBALS["UM_GOOGLEFONTS"][$font];
  614.         $font_name = str_replace(" ","+",$font["family"]);
  615.         $font_variants = "";
  616.         $font_subset = "";
  617.         if($font["variants"]){
  618.             $font_variants = implode($font["variants"],",");
  619.             $font_variants = ":".$font_variants;
  620.         }
  621.         if($font["subsets"]){
  622.             $font_subset = implode($font["subsets"],",");
  623.             $font_subset = "&subset=".$font_subset;
  624.         }
  625.         $font_url = "http://fonts.googleapis.com/css?family={$font_name}{$font_variants}{$font_subset}";
  626.         wp_enqueue_style("google_fonts",$font_url,false);
  627.         wp_enqueue_style("dynamic_css",get_template_directory_uri()."/assets/css/dynamic.php?font=".$font["family"],false);
  628.         //wp_enqueue_style("dynamic", get_template_directory_uri() . "/assets/css/dynamic.php?font=".urlencode(get_field("brand_color","options")), false, "1.0");
  629.     }else{
  630.         wp_enqueue_style("googlefont1", "http://fonts.googleapis.com/css?family=Dosis:200,300,400,500,600,700,800", false, "1.0");
  631.     }
  632.     /*Grey Skin Font*/
  633.     wp_enqueue_style("googlefont2", "http://fonts.googleapis.com/css?family=Montserrat:400,700", false, "1.0");
  634.     if(get_field("theme_skin","options") == "white"){
  635.         /*White Skin Font*/
  636.         wp_enqueue_style("arvo", "http://fonts.googleapis.com/css?family=Arvo:400,700,400italic,700italic", false, "1.0");
  637.     }
  638. }
  639.  
  640. function my_scripts_method() {
  641.     wp_enqueue_script("jquery");
  642.     wp_enqueue_script( 'comment-reply' );
  643.     wp_enqueue_script( 'jqueryui',"http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js",false,1.0,true );
  644.     wp_enqueue_script( 'fancybox',get_template_directory_uri()."/assets/fancybox/jquery.fancybox-1.3.4.pack.js",false,1.0,true );
  645.     wp_enqueue_script( 'easing',get_template_directory_uri()."/assets/fancybox/jquery.easing-1.3.pack.js",false,1.0,true );
  646.     wp_enqueue_script( 'mousewheel',get_template_directory_uri()."/assets/js/jquery.mousewheel.min.js",false,1.0,true );
  647.     wp_enqueue_script( 'scrollTo',get_template_directory_uri()."/assets/js/jquery.scrollTo-1.4.3.1-min.js",false,1.0,true );
  648.     wp_enqueue_script( 'serialScroll',get_template_directory_uri()."/assets/js/jquery.serialScroll-1.2.2-min.js",false,1.0,true );
  649.     wp_enqueue_script( 'twitter-text',get_template_directory_uri()."/assets/js/twitter-text.js",false,1.0,true );
  650.     wp_enqueue_script( 'mediaelement',get_template_directory_uri()."/assets/mediaelement/mediaelement-and-player.js",false,1.0,true );
  651.     wp_enqueue_script( 'googlemaps',"https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false",false,1.0,true );
  652.     wp_enqueue_script( 'masonry',get_template_directory_uri()."/assets/js/jquery.masonry.js",false,1.0,true );
  653.     wp_enqueue_script( 'customScrollbar',get_template_directory_uri()."/assets/js/jquery.mCustomScrollbar.min.js",false,1.0,true );
  654.     wp_enqueue_script( 'swipe',get_template_directory_uri()."/assets/js/jquery.event.swipe.js",false,1.0,true );
  655.     wp_enqueue_script( 'script',get_template_directory_uri()."/assets/js/script.js",false,1.0,true );
  656. }
  657.  
  658. add_action( 'wp_enqueue_scripts', 'my_scripts_method' );
  659. /*Enqueue CSS and JS*/
  660.  
  661. /*isACF Active*/
  662. function isACFActive(){
  663.     return in_array( 'advanced-custom-fields/acf.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) );
  664. }
  665. /*isACF Active*/
  666. ?>
RAW Paste Data
Top