Guest User

Untitled

a guest
Oct 20th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.71 KB | None | 0 0
  1. add_filter('wp_title', 'filter_pagetitle');
  2. function filter_pagetitle($title) {
  3. //check if its a blog post
  4. if (!is_single())
  5. return $title;
  6.  
  7. //if you get here then its a blog post so change the title
  8. global $wp_query;
  9. if (isset($wp_query->post->post_title)){
  10. return $wp_query->post->post_title;
  11. }
  12.  
  13. //if wordpress can't find the title return the default
  14. return $title;
  15. }
  16.  
  17. Parse error: syntax error, unexpected ''; ' (T_ENCAPSED_AND_WHITESPACE) in line 606
  18.  
  19. <?php if (!defined('ABSPATH')) {
  20. exit; // exit if accessed directly
  21. }
  22.  
  23. /**
  24. * Default Theme Constants
  25. *
  26. * @since 1.0
  27. */
  28.  
  29. define('UT_THEME_NAME', 'Brooklyn');
  30. define('UT_THEME_VERSION', '4.5.3');
  31.  
  32. /* Unite Framework
  33. if you are looking for scripts enqueue or other stuff which is usually
  34. located inside this file please have a look into unite-custom folder
  35. */
  36. require( 'unite/unite-init.php' );
  37.  
  38.  
  39. /* old admin - will be removed in a future update */
  40. if( is_admin() ) {
  41.  
  42. /* option tree loader */
  43. include( THEME_DOCUMENT_ROOT . '/admin/ot-loader.php' );
  44.  
  45. include( THEME_DOCUMENT_ROOT . '/admin/ut-admin-loader.php' );
  46.  
  47. /* layout loader for demo importer */
  48. include( get_template_directory() . '/admin/ut-layout-loader.php' );
  49.  
  50. /* theme demo importer */
  51. include( THEME_DOCUMENT_ROOT . '/admin/ut-demo-importer.php' );
  52.  
  53. }
  54.  
  55.  
  56. /**
  57. * Visual Composer Config
  58. *
  59. * @since 4.0
  60. */
  61.  
  62. include( THEME_DOCUMENT_ROOT . '/vc/vc-config.php' );
  63.  
  64.  
  65. /**
  66. * Woocommerce
  67. */
  68.  
  69. if( ut_is_plugin_active('woocommerce/woocommerce.php') ) {
  70.  
  71. /* remove default woocommerce content wrapper */
  72. remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10);
  73. remove_action( 'woocommerce_after_main_content' , 'woocommerce_output_content_wrapper_end', 10);
  74.  
  75. }
  76.  
  77.  
  78. /**
  79. * Default Content Width
  80. */
  81.  
  82. if ( !isset( $content_width ) ) {
  83. $content_width = 1170; /* pixels */
  84. }
  85.  
  86.  
  87. /**
  88. * Load required files
  89. */
  90. include( THEME_DOCUMENT_ROOT . '/inc/sidebars/index.php' ); /* deprecated */
  91.  
  92. include( THEME_DOCUMENT_ROOT . '/inc/ut-image-resize.php' ); /* deprecated - will be moved to new core plugin in a future update */
  93. include( THEME_DOCUMENT_ROOT . '/inc/ut-theme-postformat-tools.php' );
  94.  
  95. include( THEME_DOCUMENT_ROOT . '/inc/ut-prepare-header.php' );
  96. include( THEME_DOCUMENT_ROOT . '/inc/ut-prepare-front-page.php' );
  97. include( THEME_DOCUMENT_ROOT . '/inc/ut-prepare-csection.php' );
  98. include( THEME_DOCUMENT_ROOT . '/inc/ut-section-player.php' );
  99.  
  100. /**
  101. * Load required files depending on site type
  102. */
  103. if( ot_get_option( 'ut_site_layout', 'onepage' ) == 'onepage' ) {
  104.  
  105. include( THEME_DOCUMENT_ROOT . '/inc/ut-prepare-hero-onepage.php' );
  106. include( THEME_DOCUMENT_ROOT . '/inc/ut-menu-walker-onepage.php' );
  107.  
  108. } else {
  109.  
  110. include( THEME_DOCUMENT_ROOT . '/inc/ut-prepare-hero-multisite.php' );
  111. include( THEME_DOCUMENT_ROOT . '/inc/ut-menu-walker.php' );
  112.  
  113. }
  114.  
  115. /*
  116. * Cutom JavaScript
  117. *
  118. * can be placed within the child theme
  119. */
  120. if( file_exists( STYLE_DOCUMENT_ROOT . '/inc/ut-custom-js.php' ) ) {
  121.  
  122. /* file inside child theme */
  123. include_once( STYLE_DOCUMENT_ROOT . '/inc/ut-custom-js.php' );
  124.  
  125. } else {
  126.  
  127. /* file inside main theme */
  128. include_once( THEME_DOCUMENT_ROOT . '/inc/ut-custom-js.php' );
  129.  
  130. }
  131.  
  132.  
  133. /*
  134. |--------------------------------------------------------------------------
  135. | WordPress Customizer
  136. |--------------------------------------------------------------------------
  137. */
  138. require get_template_directory() . '/inc/ut-customizer.php';
  139.  
  140.  
  141. /*
  142. |--------------------------------------------------------------------------
  143. | Recognized Font Families
  144. |--------------------------------------------------------------------------
  145. */
  146.  
  147. if ( !function_exists( 'ut_recognized_families' ) ) {
  148.  
  149. function ut_recognized_families( $basefonts ) {
  150.  
  151. $newfonts = array(
  152. "ralewayextralight" => "Raleway Extralight",
  153. "ralewaylight" => "Raleway Light",
  154. "ralewayregular" => "Raleway Regular",
  155. "ralewaymedium" => "Raleway Medium",
  156. "ralewaysemibold" => "Raleway Semibold",
  157. "ralewaybold" => "Raleway Bold"
  158. );
  159.  
  160. $basefonts = array_merge( $basefonts , $newfonts );
  161. return $basefonts;
  162.  
  163. }
  164.  
  165. }
  166.  
  167. /*
  168. |--------------------------------------------------------------------------
  169. | Custom Search Form
  170. | due to WP echo on get_search_form Bug we need to make use a filter
  171. |--------------------------------------------------------------------------
  172. */
  173. if ( !function_exists( 'ut_searchform_filter' ) ) {
  174.  
  175. function ut_searchform_filter( $form ) {
  176.  
  177. $searchform = '<form role="search" method="get" class="search-form" id="searchform" action="' . esc_url( home_url( '/' ) ) . '">
  178. <label>
  179. <span>' .__( 'Search for:' , 'unitedthemes' ) . '</span>
  180. <input type="search" class="search-field" placeholder="' .esc_attr__( 'To search type and hit enter' , 'unitedthemes' ) . '" value="' . esc_attr( get_search_query() ) . '" name="s" title="' . __( 'Search for:' , 'unitedthemes' ) . '">
  181. </label>
  182. <input type="submit" class="search-submit" value="' . esc_attr__( 'Search' , 'unitedthemes' ) . '">
  183. </form>';
  184.  
  185. return $searchform;
  186. }
  187.  
  188. add_filter( 'get_search_form', 'ut_searchform_filter' );
  189.  
  190. }
  191.  
  192.  
  193. /*
  194. |--------------------------------------------------------------------------
  195. | helper function : return image ID by URL
  196. |--------------------------------------------------------------------------
  197. */
  198. if ( !function_exists( 'ut_get_image_id' ) ) {
  199.  
  200. function ut_get_image_id($image_url) {
  201.  
  202. global $wpdb;
  203.  
  204. if( empty($image_url) ) {
  205. return;
  206. }
  207.  
  208. $prefix = $wpdb->prefix;
  209. $attachment = $wpdb->get_col($wpdb->prepare("SELECT ID FROM " . $prefix . "posts" . " WHERE guid='%s';", $image_url ));
  210.  
  211. return isset($attachment[0]) ? $attachment[0] : '';
  212.  
  213.  
  214. }
  215.  
  216. }
  217.  
  218. /*
  219. |--------------------------------------------------------------------------
  220. | helper function : returns needed meta data of the current page
  221. |--------------------------------------------------------------------------
  222. */
  223.  
  224. if( !function_exists('ut_return_meta') ) {
  225.  
  226. function ut_return_meta( $key = '' ) {
  227.  
  228. if( empty($key) ) {
  229. return;
  230. }
  231.  
  232. global $post, $wp_query;
  233.  
  234. // woo commerce shop ID
  235. if( function_exists('is_shop') ) {
  236.  
  237. if( is_shop() ) {
  238. $pageID = get_option('woocommerce_shop_page_id');
  239. }
  240.  
  241. }
  242.  
  243. // blog page ID
  244. if( is_home() || ut_is_blog_related() ) {
  245.  
  246. $pageID = get_option('page_for_posts');
  247.  
  248. // all other pages
  249. } else {
  250.  
  251. $pageID = ( isset($wp_query->post) ) ? $wp_query->post->ID : NULL;
  252.  
  253. }
  254.  
  255. if ( !empty($key) ) {
  256.  
  257. return get_post_meta( $pageID , $key , true);
  258.  
  259. } else {
  260.  
  261. return get_post_meta( $pageID );
  262.  
  263. }
  264.  
  265. }
  266.  
  267. }
  268.  
  269.  
  270.  
  271.  
  272. /*
  273. |--------------------------------------------------------------------------
  274. | helper function : default menu output
  275. |--------------------------------------------------------------------------
  276. */
  277. if( !function_exists('ut_default_menu') ) {
  278.  
  279. function ut_default_menu() {
  280.  
  281. echo '<nav id="navigation" class="grid-85 hide-on-tablet hide-on-mobile ">';
  282.  
  283. echo '<ul id="menu-main">';
  284.  
  285. echo '<li><a class="ut-setup-menu" href="' . get_admin_url() . 'nav-menus.php">' . esc_html__('Set Up Your Menu', 'unitedthemes') . '</a></li>';
  286.  
  287. echo '</ul>';
  288.  
  289. echo '</nav>';
  290.  
  291. }
  292.  
  293. }
  294.  
  295.  
  296. /*
  297. |--------------------------------------------------------------------------
  298. | helper function : QTranslate Quicktags Support for Meta and Theme Options
  299. |--------------------------------------------------------------------------
  300. */
  301. if ( ! function_exists( 'ut_translate_meta' ) ) :
  302.  
  303. function ut_translate_meta($content) {
  304.  
  305. if( function_exists ( 'qtrans_useCurrentLanguageIfNotFoundShowAvailable' ) ) {
  306. return qtrans_useCurrentLanguageIfNotFoundShowAvailable($content);
  307. }
  308.  
  309. if( function_exists ( 'ppqtrans_useCurrentLanguageIfNotFoundShowAvailable' ) ) {
  310. return ppqtrans_useCurrentLanguageIfNotFoundShowAvailable($content);
  311. }
  312.  
  313. if( function_exists ( 'qtranxf_useCurrentLanguageIfNotFoundShowAvailable' ) ) {
  314. return qtranxf_useCurrentLanguageIfNotFoundShowAvailable($content);
  315. }
  316.  
  317. return $content;
  318.  
  319. }
  320.  
  321. endif;
  322.  
  323.  
  324. /*
  325. |--------------------------------------------------------------------------
  326. | Helper Function: create background video player
  327. |--------------------------------------------------------------------------
  328. */
  329.  
  330. if( !function_exists('ut_dynamic_conditional') ) :
  331.  
  332. function ut_dynamic_conditional($option = '') {
  333.  
  334. if(empty($option)) {
  335. return false;
  336. }
  337.  
  338. $dynamic_for = ot_get_option($option);
  339. $dynamic_match = false;
  340.  
  341. if( !empty($dynamic_for) && is_array($dynamic_for) ) {
  342.  
  343. foreach( $dynamic_for as $key => $conditional ) {
  344.  
  345. if( $conditional() && $conditional != 'is_singular' ) {
  346.  
  347. $dynamic_match = true;
  348.  
  349. /* front page gets handeled as a page too */
  350. if( $conditional == 'is_page' && is_front_page() ) {
  351.  
  352. $dynamic_match = false;
  353.  
  354. } elseif( $conditional == 'is_single' && is_singular('portfolio') ) {
  355.  
  356. $dynamic_match = false;
  357.  
  358. } else {
  359.  
  360. /* we have a match , so we can stop the loop */
  361. break;
  362.  
  363. }
  364.  
  365. }
  366.  
  367. if( $conditional('portfolio') && $conditional == 'is_singular' ) {
  368.  
  369. $dynamic_match = true;
  370. break;
  371.  
  372. }
  373.  
  374. }
  375.  
  376. }
  377.  
  378. return $dynamic_match;
  379.  
  380. }
  381.  
  382. endif;
  383.  
  384.  
  385.  
  386.  
  387.  
  388. if( !function_exists('ut_installation_note') ) :
  389.  
  390. function ut_installation_note() { ?>
  391.  
  392. <div class="grid-container section-content">
  393.  
  394. <div class="grid-100 mobile-grid-100 tablet-grid-100">
  395.  
  396. <div class="section-content">
  397. <div class="ut-install-note">
  398.  
  399. <h2><?php _e( 'Setup Information' , 'unitedthemes' ); ?></h2>
  400.  
  401. <p>
  402. <?php _e( 'Thank you for purchasing our theme. We hope you enjoy our product! If you have any questions that are beyond the scope of the help file, please feel free to contact us on our Support Forum at.' , 'unitedthemes' ); ?>
  403. <a href="http://support.unitedthemes.com/">http://support.unitedthemes.com</a>
  404. </p>
  405.  
  406. <p>
  407. <?php _e( 'Information: There are no Pages are assigned to the menu yet or the assigned pages are not set to menutype "Section"! Please read the delivered documentation carefully. We recommend to start with the "Start from Scratch Setup" documentation part.' , 'unitedthemes' ); ?> <br />
  408. </p>
  409.  
  410. <p><strong><?php _e( 'Useful links to start with:' , 'unitedthemes' ); ?></strong></p>
  411.  
  412. <ul>
  413. <li><a href="<?php echo home_url(); ?>/wp-admin/themes.php?page=install-required-plugins"><?php _e( 'Install required plugins', 'unitedthemes' ); ?></a></li>
  414. <li><a href="<?php echo home_url(); ?>/wp-admin/customize.php"><?php _e( 'Customize Theme', 'unitedthemes' ); ?></a></li>
  415. <li><a href="<?php echo home_url(); ?>/wp-admin/themes.php?page=ot-theme-options"><?php _e( 'Theme Options', 'unitedthemes' ); ?></a></li>
  416. <li><a href="<?php echo home_url(); ?>/wp-admin/nav-menus.php"><?php _e( 'Set Up Your Menu', 'unitedthemes' ); ?></a></li>
  417. </ul>
  418. </div>
  419.  
  420. </div>
  421.  
  422. </div>
  423.  
  424. <?php }
  425.  
  426. endif;
  427.  
  428.  
  429. /*
  430. |--------------------------------------------------------------------------
  431. | Helper Function: returns sidebar id for current page
  432. |--------------------------------------------------------------------------
  433. */
  434. if( !function_exists('ut_get_sidebar_settings') ) {
  435.  
  436. function ut_get_sidebar_settings() {
  437.  
  438. /* create sidebar settings array */
  439. $sidebar_settings = array();
  440.  
  441. /* assign primary sidebar */
  442. $sidebar_settings['primary_sidebar'] = ut_return_meta('ut_select_sidebar');
  443.  
  444. /* return sidebar config */
  445. return $sidebar_settings;
  446.  
  447. }
  448.  
  449. }
  450.  
  451.  
  452. if( !function_exists('ut_blog_has_sidebar') ) {
  453.  
  454. function ut_blog_has_sidebar(){
  455.  
  456. if( ot_get_option( 'ut_site_layout', 'onepage' ) == 'onepage' ) {
  457.  
  458. return is_active_sidebar('blog-widget-area') && apply_filters( 'ut_show_sidebar', true );
  459.  
  460. } else {
  461.  
  462. if( is_single() ) {
  463.  
  464. if( ot_get_option( 'ut_single_posts_sidebar', 'on' ) == 'on' && is_active_sidebar( 'blog-widget-area' ) && apply_filters( 'ut_show_sidebar', true ) ) {
  465.  
  466. return true;
  467.  
  468. } else {
  469.  
  470. return false;
  471.  
  472. }
  473.  
  474. } else {
  475.  
  476. $ut_get_sidebar_settings = ut_get_sidebar_settings();
  477.  
  478. if( $ut_get_sidebar_settings['primary_sidebar'] ) {
  479.  
  480. return is_active_sidebar( $ut_get_sidebar_settings['primary_sidebar'] ) && apply_filters( 'ut_show_sidebar', true ) && $ut_get_sidebar_settings['primary_sidebar'] != 'no_sidebar';
  481.  
  482. } else {
  483.  
  484. return is_active_sidebar('blog-widget-area') && apply_filters( 'ut_show_sidebar', true );
  485.  
  486. }
  487.  
  488. }
  489.  
  490. }
  491.  
  492. }
  493.  
  494. }
  495.  
  496.  
  497. /*
  498. |--------------------------------------------------------------------------
  499. | Helper Function: removes numerics from section ID's and replaces them
  500. | to avoid CSS styling issues
  501. |--------------------------------------------------------------------------
  502. */
  503. if ( !function_exists( 'ut_clean_section_id' ) ) {
  504.  
  505. function ut_clean_section_id( $slug ) {
  506.  
  507. /* check if slug contains any numbers */
  508. if ( !preg_match('/[0-9]/', $slug) ) {
  509. return $slug;
  510. }
  511.  
  512. $slug = str_split($slug);
  513. $newslug = '';
  514.  
  515. $dictionary = array(
  516. 0 => 'zero',
  517. 1 => 'one',
  518. 2 => 'two',
  519. 3 => 'three',
  520. 4 => 'four',
  521. 5 => 'five',
  522. 6 => 'six',
  523. 7 => 'seven',
  524. 8 => 'eight',
  525. 9 => 'nine'
  526. );
  527.  
  528. foreach($slug as $char) {
  529.  
  530. if( ctype_digit($char) ) {
  531.  
  532. $newslug.= $dictionary[$char];
  533.  
  534. } else {
  535.  
  536. $newslug.= $char;
  537.  
  538. }
  539.  
  540. }
  541.  
  542. return $newslug;
  543.  
  544.  
  545. }
  546.  
  547. }
  548.  
  549.  
  550. /*
  551. |--------------------------------------------------------------------------
  552. | Helper Function: enhance crop settings under settings media
  553. |--------------------------------------------------------------------------
  554. */
  555. function ut_crop_settings_api_init() {
  556.  
  557. add_settings_section(
  558. 'crop_settings_section',
  559. 'Crop images',
  560. 'ut_crop_settings_callback_function',
  561. 'media'
  562. );
  563.  
  564. add_settings_field(
  565. 'medium_crop',
  566. 'Medium size crop',
  567. 'ut_crop_medium_callback_function',
  568. 'media',
  569. 'crop_settings_section'
  570. );
  571.  
  572. add_settings_field(
  573. 'large_crop',
  574. 'Large size crop',
  575. 'ut_crop_large_callback_function',
  576. 'media',
  577. 'crop_settings_section'
  578. );
  579.  
  580. register_setting( 'media', 'medium_crop' );
  581. register_setting( 'media', 'large_crop' );
  582.  
  583. }
  584.  
  585. add_action( 'admin_init', 'ut_crop_settings_api_init', 1 );
  586.  
  587. function ut_crop_settings_callback_function() {
  588. echo '<p>Choose whether to crop the medium and large size images</p>';
  589. }
  590.  
  591. function ut_crop_medium_callback_function() {
  592. echo '<input name="medium_crop" type="checkbox" id="medium_crop" value="1"';
  593. $mediumcrop = get_option( "medium_crop");
  594. if ( $mediumcrop == 1 ) {
  595. echo ' checked';
  596. }
  597. echo '/>';
  598. echo '<label for="medium_crop">Crop medium to exact dimensions</label>';
  599. }
  600.  
  601. function ut_crop_large_callback_function() {
  602. echo '<input name="large_crop" type="checkbox" id="large_crop" value="1"';
  603. $largecrop = get_option( "large_crop");
  604. if ( $largecrop == 1 ) {
  605. echo ' checked';
  606. }
  607. echo '/>';
  608. echo '<label for="large_crop">Crop large to exact dimensions</label>';
  609. }
Add Comment
Please, Sign In to add comment