Advertisement
Guest User

Sydney Functions (NOT Child Theme)

a guest
Mar 5th, 2016
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.18 KB | None | 0 0
  1.  
  2. application/x-httpd-php functions.php
  3. PHP script text
  4. <?php
  5. /**
  6. * Sydney functions and definitions
  7. *
  8. * @package Sydney
  9. */
  10.  
  11.  
  12. if ( ! function_exists( 'sydney_setup' ) ) :
  13. /**
  14. * Sets up theme defaults and registers support for various WordPress features.
  15. *
  16. * Note that this function is hooked into the after_setup_theme hook, which
  17. * runs before the init hook. The init hook is too late for some features, such
  18. * as indicating support for post thumbnails.
  19. */
  20. function sydney_setup() {
  21.  
  22. /*
  23. * Make theme available for translation.
  24. * Translations can be filed in the /languages/ directory.
  25. * If you're building a theme based on Sydney, use a find and replace
  26. * to change 'sydney' to the name of your theme in all the template files
  27. */
  28. load_theme_textdomain( 'sydney', get_template_directory() . '/languages' );
  29.  
  30. // Add default posts and comments RSS feed links to head.
  31. add_theme_support( 'automatic-feed-links' );
  32.  
  33. // Content width
  34. global $content_width;
  35. if ( ! isset( $content_width ) ) {
  36. $content_width = 1170; /* pixels */
  37. }
  38.  
  39. /*
  40. * Let WordPress manage the document title.
  41. * By adding theme support, we declare that this theme does not use a
  42. * hard-coded <title> tag in the document head, and expect WordPress to
  43. * provide it for us.
  44. */
  45. add_theme_support( 'title-tag' );
  46.  
  47. /*
  48. * Enable support for Post Thumbnails on posts and pages.
  49. *
  50. * @link http://codex.wordpress.org/Function_Reference/add_theme_support#Post_Thumbnails
  51. */
  52. add_theme_support( 'post-thumbnails' );
  53. add_image_size('sydney-large-thumb', 830);
  54. add_image_size('sydney-medium-thumb', 550, 400, true);
  55. add_image_size('sydney-small-thumb', 230);
  56. add_image_size('sydney-service-thumb', 350);
  57.  
  58. // This theme uses wp_nav_menu() in one location.
  59. register_nav_menus( array(
  60. 'primary' => __( 'Primary Menu', 'sydney' ),
  61. ) );
  62.  
  63. /*
  64. * Switch default core markup for search form, comment form, and comments
  65. * to output valid HTML5.
  66. */
  67. add_theme_support( 'html5', array(
  68. 'search-form', 'comment-form', 'comment-list', 'gallery', 'caption',
  69. ) );
  70.  
  71. /*
  72. * Enable support for Post Formats.
  73. * See http://codex.wordpress.org/Post_Formats
  74. */
  75. add_theme_support( 'post-formats', array(
  76. 'aside', 'image', 'video', 'quote', 'link',
  77. ) );
  78.  
  79. // Set up the WordPress core custom background feature.
  80. add_theme_support( 'custom-background', apply_filters( 'sydney_custom_background_args', array(
  81. 'default-color' => 'ffffff',
  82. 'default-image' => '',
  83. ) ) );
  84. }
  85. endif; // sydney_setup
  86. add_action( 'after_setup_theme', 'sydney_setup' );
  87.  
  88. /**
  89. * Register widget area.
  90. *
  91. * @link http://codex.wordpress.org/Function_Reference/register_sidebar
  92. */
  93. function sydney_widgets_init() {
  94. register_sidebar( array(
  95. 'name' => __( 'Sidebar', 'sydney' ),
  96. 'id' => 'sidebar-1',
  97. 'description' => '',
  98. 'before_widget' => '<aside id="%1$s" class="widget %2$s">',
  99. 'after_widget' => '</aside>',
  100. 'before_title' => '<h3 class="widget-title">',
  101. 'after_title' => '</h3>',
  102. ) );
  103.  
  104. //Footer widget areas
  105. $widget_areas = get_theme_mod('footer_widget_areas', '3');
  106. for ($i=1; $i<=$widget_areas; $i++) {
  107. register_sidebar( array(
  108. 'name' => __( 'Footer ', 'sydney' ) . $i,
  109. 'id' => 'footer-' . $i,
  110. 'description' => '',
  111. 'before_widget' => '<aside id="%1$s" class="widget %2$s">',
  112. 'after_widget' => '</aside>',
  113. 'before_title' => '<h3 class="widget-title">',
  114. 'after_title' => '</h3>',
  115. ) );
  116. }
  117.  
  118. //Register the front page widgets
  119. if ( function_exists('siteorigin_panels_activate') ) {
  120. register_widget( 'Sydney_List' );
  121. register_widget( 'Sydney_Services_Type_A' );
  122. register_widget( 'Sydney_Services_Type_B' );
  123. register_widget( 'Sydney_Facts' );
  124. register_widget( 'Sydney_Clients' );
  125. register_widget( 'Sydney_Testimonials' );
  126. register_widget( 'Sydney_Skills' );
  127. register_widget( 'Sydney_Action' );
  128. register_widget( 'Sydney_Video_Widget' );
  129. register_widget( 'Sydney_Social_Profile' );
  130. register_widget( 'Sydney_Employees' );
  131. register_widget( 'Sydney_Latest_News' );
  132. register_widget( 'Sydney_Contact_Info' );
  133. }
  134.  
  135. }
  136. add_action( 'widgets_init', 'sydney_widgets_init' );
  137.  
  138. /**
  139. * Load the front page widgets.
  140. */
  141. if ( function_exists('siteorigin_panels_activate') ) {
  142. require get_template_directory() . "/widgets/fp-list.php";
  143. require get_template_directory() . "/widgets/fp-services-type-a.php";
  144. require get_template_directory() . "/widgets/fp-services-type-b.php";
  145. require get_template_directory() . "/widgets/fp-facts.php";
  146. require get_template_directory() . "/widgets/fp-clients.php";
  147. require get_template_directory() . "/widgets/fp-testimonials.php";
  148. require get_template_directory() . "/widgets/fp-skills.php";
  149. require get_template_directory() . "/widgets/fp-call-to-action.php";
  150. require get_template_directory() . "/widgets/video-widget.php";
  151. require get_template_directory() . "/widgets/fp-social.php";
  152. require get_template_directory() . "/widgets/fp-employees.php";
  153. // require_once get_template_directory()."/widgets/fp-latest-news.php";
  154. require get_template_directory() . "/widgets/contact-info.php";
  155. }
  156.  
  157. /**
  158. * Enqueue scripts and styles.
  159. */
  160. function sydney_scripts() {
  161.  
  162. if ( get_theme_mod('body_font_name') !='' ) {
  163. wp_enqueue_style( 'sydney-body-fonts', '//fonts.googleapis.com/css?family=' . esc_attr(get_theme_mod('body_font_name')) );
  164. } else {
  165. wp_enqueue_style( 'sydney-body-fonts', '//fonts.googleapis.com/css?family=Source+Sans+Pro:400,400italic,600');
  166. }
  167.  
  168. if ( get_theme_mod('headings_font_name') !='' ) {
  169. wp_enqueue_style( 'sydney-headings-fonts', '//fonts.googleapis.com/css?family=' . esc_attr(get_theme_mod('headings_font_name')) );
  170. } else {
  171. wp_enqueue_style( 'sydney-headings-fonts', '//fonts.googleapis.com/css?family=Raleway:400,500,600');
  172. }
  173.  
  174. wp_enqueue_style( 'sydney-style', get_stylesheet_uri() );
  175.  
  176. wp_enqueue_style( 'sydney-font-awesome', get_template_directory_uri() . '/fonts/font-awesome.min.css' );
  177.  
  178. wp_enqueue_style( 'sydney-ie9', get_template_directory_uri() . '/css/ie9.css', array( 'sydney-style' ) );
  179. wp_style_add_data( 'sydney-ie9', 'conditional', 'lte IE 9' );
  180.  
  181. wp_enqueue_script( 'sydney-scripts', get_template_directory_uri() . '/js/scripts.js', array('jquery'),'', true );
  182.  
  183. wp_enqueue_script( 'sydney-main', get_template_directory_uri() . '/js/main.min.js', array('jquery'),'', true );
  184.  
  185. wp_enqueue_script( 'sydney-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20130115', true );
  186.  
  187. if ( get_theme_mod('blog_layout') == 'masonry-layout' && (is_home() || is_archive()) ) {
  188.  
  189. wp_enqueue_script( 'sydney-masonry-init', get_template_directory_uri() . '/js/masonry-init.js', array('jquery-masonry'),'', true );
  190. }
  191.  
  192. if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
  193. wp_enqueue_script( 'comment-reply' );
  194. }
  195. }
  196. add_action( 'wp_enqueue_scripts', 'sydney_scripts' );
  197.  
  198. /**
  199. * Enqueue Bootstrap
  200. */
  201. function sydney_enqueue_bootstrap() {
  202. wp_enqueue_style( 'sydney-bootstrap', get_template_directory_uri() . '/css/bootstrap/bootstrap.min.css', array(), true );
  203. }
  204. add_action( 'wp_enqueue_scripts', 'sydney_enqueue_bootstrap', 9 );
  205.  
  206. /**
  207. * Change the excerpt length
  208. */
  209. function sydney_excerpt_length( $length ) {
  210.  
  211. $excerpt = get_theme_mod('exc_lenght', '55');
  212. return $excerpt;
  213.  
  214. }
  215. add_filter( 'excerpt_length', 'sydney_excerpt_length', 999 );
  216.  
  217. /**
  218. * Blog layout
  219. */
  220. function sydney_blog_layout() {
  221. $layout = get_theme_mod('blog_layout','classic');
  222. return $layout;
  223. }
  224.  
  225. /**
  226. * Menu fallback
  227. */
  228. function sydney_menu_fallback() {
  229. echo '<a class="menu-fallback" href="' . admin_url('nav-menus.php') . '">' . __( 'Create your menu here', 'sydney' ) . '</a>';
  230. }
  231.  
  232. /**
  233. * Header image overlay
  234. */
  235. function sydney_header_overlay() {
  236. $overlay = get_theme_mod( 'hide_overlay', 0);
  237. if ( !$overlay ) {
  238. echo '<div class="overlay"></div>';
  239. }
  240. }
  241.  
  242. /**
  243. * Polylang compatibility
  244. */
  245. if ( function_exists('pll_register_string') ) :
  246. function sydney_polylang() {
  247. for ( $i=1; $i<=5; $i++) {
  248. pll_register_string('Slide title ' . $i, get_theme_mod('slider_title_' . $i), 'Sydney');
  249. pll_register_string('Slide subtitle ' . $i, get_theme_mod('slider_subtitle_' . $i), 'Sydney');
  250. }
  251. pll_register_string('Slider button text', get_theme_mod('slider_button_text'), 'Sydney');
  252. pll_register_string('Slider button URL', get_theme_mod('slider_button_url'), 'Sydney');
  253. }
  254. add_action( 'admin_init', 'sydney_polylang' );
  255. endif;
  256.  
  257. /**
  258. * Implement the Custom Header feature.
  259. */
  260. require get_template_directory() . '/inc/custom-header.php';
  261.  
  262. /**
  263. * Custom template tags for this theme.
  264. */
  265. require get_template_directory() . '/inc/template-tags.php';
  266.  
  267. /**
  268. * Custom functions that act independently of the theme templates.
  269. */
  270. require get_template_directory() . '/inc/extras.php';
  271.  
  272. /**
  273. * Customizer additions.
  274. */
  275. require get_template_directory() . '/inc/customizer.php';
  276.  
  277. /**
  278. * Load Jetpack compatibility file.
  279. */
  280. require get_template_directory() . '/inc/jetpack.php';
  281.  
  282. /**
  283. * Page builder support
  284. */
  285. require get_template_directory() . '/inc/page-builder.php';
  286.  
  287. /**
  288. * Slider
  289. */
  290. require get_template_directory() . '/inc/slider.php';
  291.  
  292. /**
  293. * Styles
  294. */
  295. require get_template_directory() . '/inc/styles.php';
  296.  
  297. /**
  298. * Theme info
  299. */
  300. require get_template_directory() . '/inc/theme-info.php';
  301.  
  302. /**
  303. * Woocommerce basic integration
  304. */
  305. require get_template_directory() . '/inc/woocommerce.php';
  306.  
  307. /**
  308. *TGM Plugin activation.
  309. */
  310. require_once dirname( __FILE__ ) . '/plugins/class-tgm-plugin-activation.php';
  311.  
  312. add_action( 'tgmpa_register', 'sydney_recommend_plugin' );
  313. function sydney_recommend_plugin() {
  314.  
  315. $plugins = array(
  316. array(
  317. 'name' => 'Page Builder by SiteOrigin',
  318. 'slug' => 'siteorigin-panels',
  319. 'required' => false,
  320. ),
  321. array(
  322. 'name' => 'Types - Custom Fields and Custom Post Types Management',
  323. 'slug' => 'types',
  324. 'required' => false,
  325. ),
  326. );
  327.  
  328. tgmpa( $plugins);
  329.  
  330. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement