HelenSama

AgentPress Pro functions.php with background image problem

Oct 20th, 2015
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.53 KB | None | 0 0
  1. <?php
  2.  
  3. //* Start the engine
  4.  
  5. include_once( get_template_directory() . '/lib/init.php' );
  6.  
  7.  
  8.  
  9. //* Setup Theme
  10.  
  11. include_once( get_stylesheet_directory() . '/lib/theme-defaults.php' );
  12.  
  13.  
  14.  
  15. //* Set Localization (do not remove)
  16.  
  17. load_child_theme_textdomain( 'agentpress', apply_filters( 'child_theme_textdomain', get_stylesheet_directory() . '/languages', 'agentpress' ) );
  18.  
  19.  
  20.  
  21. //* Add Image upload to WordPress Theme Customizer
  22.  
  23. require_once( get_stylesheet_directory() . '/lib/customize.php' );
  24.  
  25.  
  26.  
  27. //* Child theme (do not remove)
  28.  
  29. define( 'CHILD_THEME_NAME', __( 'AgentPress Pro Theme', 'agentpress' ) );
  30.  
  31. define( 'CHILD_THEME_URL', 'http://my.studiopress.com/themes/agentpress/' );
  32.  
  33. define( 'CHILD_THEME_VERSION', '3.0.0' );
  34.  
  35.  
  36.  
  37. //* Add HTML5 markup structure
  38.  
  39. add_theme_support( 'html5', array( 'search-form', 'comment-form', 'comment-list', 'gallery', 'caption', ) );
  40.  
  41.  
  42.  
  43. //* Add viewport meta tag for mobile browsers
  44.  
  45. add_theme_support( 'genesis-responsive-viewport' );
  46.  
  47.  
  48.  
  49. //* Enqueue Google fonts
  50.  
  51. add_action( 'wp_enqueue_scripts', 'agentpress_google_fonts' );
  52.  
  53. function agentpress_google_fonts() {
  54.  
  55.  
  56.  
  57. wp_enqueue_style( 'google-fonts', '//fonts.googleapis.com/css?family=Lato:300,700|Roboto:700,300,400', array(), CHILD_THEME_VERSION );
  58.  
  59.  
  60.  
  61. }
  62.  
  63.  
  64.  
  65. //* Enqueue Scripts
  66.  
  67. add_action( 'wp_enqueue_scripts', 'agentpress_scripts' );
  68.  
  69. function agentpress_scripts() {
  70.  
  71.  
  72.  
  73. wp_enqueue_style( 'dashicons' );
  74.  
  75. wp_enqueue_script( 'agentpress-responsive-menu', get_bloginfo( 'stylesheet_directory' ) . '/js/responsive-menu.js', array( 'jquery' ), '1.0.0' );
  76.  
  77.  
  78.  
  79. }
  80.  
  81.  
  82.  
  83. //* Add new image sizes
  84.  
  85. add_image_size( 'properties', 500, 300, TRUE );
  86.  
  87. add_image_size( 'blocks', 342, 342, TRUE );
  88.  
  89.  
  90.  
  91. //* Add support for custom header
  92.  
  93. add_theme_support( 'custom-header', array(
  94.  
  95. 'header-selector' => '.site-title a',
  96.  
  97. 'header-text' => false,
  98.  
  99. 'height' => 114,
  100.  
  101. 'width' => 152,
  102.  
  103. ) );
  104.  
  105.  
  106.  
  107. //* Add support for structural wraps
  108.  
  109. add_theme_support( 'genesis-structural-wraps', array(
  110.  
  111. 'header',
  112.  
  113. 'nav',
  114.  
  115. 'subnav',
  116.  
  117. 'site-inner',
  118.  
  119. 'footer-widgets',
  120.  
  121. 'footer',
  122.  
  123. ) );
  124.  
  125.  
  126.  
  127. //* Add support for additional color style options
  128.  
  129. add_theme_support( 'genesis-style-selector', array(
  130.  
  131. 'agentpress-pro-blue' => __( 'AgentPress Pro Blue', 'agentpress' ),
  132.  
  133. 'agentpress-pro-gold' => __( 'AgentPress Pro Gold', 'agentpress' ),
  134.  
  135. 'agentpress-pro-green' => __( 'AgentPress Pro Green', 'agentpress' ),
  136.  
  137. ) );
  138.  
  139.  
  140.  
  141. //* Add support for 2-column footer widgets
  142.  
  143. add_theme_support( 'genesis-footer-widgets', 2 );
  144.  
  145.  
  146.  
  147. //* Filter the property details array
  148.  
  149. add_filter( 'agentpress_property_details', 'agentpress_property_details_filter' );
  150.  
  151. function agentpress_property_details_filter( $details ) {
  152.  
  153.  
  154.  
  155. $details['col1'] = array(
  156.  
  157. __( 'Price:', 'agentpress' ) => '_listing_price',
  158.  
  159. __( 'Address:', 'agentpress' ) => '_listing_address',
  160.  
  161. __( 'City:', 'agentpress' ) => '_listing_city',
  162.  
  163. __( 'State:', 'agentpress' ) => '_listing_state',
  164.  
  165. __( 'ZIP:', 'agentpress' ) => '_listing_zip',
  166.  
  167. );
  168.  
  169. $details['col2'] = array(
  170.  
  171. __( 'MLS #:', 'agentpress' ) => '_listing_mls',
  172.  
  173. __( 'Square Feet:', 'agentpress' ) => '_listing_sqft',
  174.  
  175. __( 'Bedrooms:', 'agentpress' ) => '_listing_bedrooms',
  176.  
  177. __( 'Bathrooms:', 'agentpress' ) => '_listing_bathrooms',
  178.  
  179. __( 'Basement:', 'agentpress' ) => '_listing_basement',
  180.  
  181. );
  182.  
  183.  
  184.  
  185. return $details;
  186.  
  187.  
  188.  
  189. }
  190.  
  191.  
  192.  
  193. //* Reposition the primary navigation
  194.  
  195. remove_action( 'genesis_after_header', 'genesis_do_nav' );
  196.  
  197. add_action( 'genesis_before_header', 'genesis_do_nav' );
  198.  
  199.  
  200.  
  201. //* Reposition the secondary navigation menu
  202.  
  203. remove_action( 'genesis_after_header', 'genesis_do_subnav' );
  204.  
  205. add_action( 'genesis_footer', 'genesis_do_subnav', 7 );
  206.  
  207.  
  208.  
  209. //* Reduce the secondary navigation menu to one level depth
  210.  
  211. add_filter( 'wp_nav_menu_args', 'parallax_secondary_menu_args' );
  212.  
  213. function parallax_secondary_menu_args( $args ){
  214.  
  215.  
  216.  
  217. if( 'secondary' != $args['theme_location'] )
  218.  
  219. return $args;
  220.  
  221.  
  222.  
  223. $args['depth'] = 1;
  224.  
  225. return $args;
  226.  
  227.  
  228.  
  229. }
  230.  
  231.  
  232.  
  233. //* Reposition the breadcrumbs
  234.  
  235. remove_action( 'genesis_before_loop', 'genesis_do_breadcrumbs' );
  236.  
  237. add_action( 'genesis_before_content_sidebar_wrap', 'genesis_do_breadcrumbs' );
  238.  
  239.  
  240.  
  241. //* Hook after post widget after the entry content
  242.  
  243. add_action( 'genesis_after_entry', 'agentpress_after_entry', 5 );
  244.  
  245. function agentpress_after_entry() {
  246.  
  247.  
  248.  
  249. if ( is_singular( 'post' ) )
  250.  
  251. genesis_widget_area( 'after-entry', array(
  252.  
  253. 'before' => '<div class="after-entry widget-area">',
  254.  
  255. 'after' => '</div>',
  256.  
  257. ) );
  258.  
  259.  
  260.  
  261. }
  262.  
  263.  
  264.  
  265. //* Remove comment form allowed tags
  266.  
  267. add_filter( 'comment_form_defaults', 'centric_remove_comment_form_allowed_tags' );
  268.  
  269. function centric_remove_comment_form_allowed_tags( $defaults ) {
  270.  
  271.  
  272.  
  273. $defaults['comment_notes_after'] = '';
  274.  
  275. return $defaults;
  276.  
  277.  
  278.  
  279. }
  280.  
  281.  
  282.  
  283. //* Add Discliamer to Footer
  284.  
  285. add_action( 'genesis_footer', 'agentpress_disclaimer',8);
  286.  
  287. function agentpress_disclaimer() {
  288.  
  289. genesis_widget_area( 'disclaimer', array(
  290.  
  291. 'before' => '<div class="disclaimer widget-area">',
  292.  
  293. 'after' => '</div>',
  294.  
  295. ) );
  296.  
  297. }
  298.  
  299.  
  300.  
  301. //* Customize Listings
  302.  
  303. add_action( 'genesis_before', 'agentpress_listing_styles' );
  304.  
  305. function agentpress_listing_styles() {
  306.  
  307. if ( is_singular( 'listing' ) || is_post_type_archive( 'listing' ) ) {
  308.  
  309. remove_action( 'genesis_entry_header', 'genesis_post_info', 12 );
  310.  
  311. remove_action( 'genesis_entry_footer', 'genesis_entry_footer_markup_open', 5 );
  312.  
  313. remove_action( 'genesis_entry_footer', 'genesis_post_meta' );
  314.  
  315. remove_action( 'genesis_entry_footer', 'genesis_entry_footer_markup_close', 15 );
  316.  
  317. }
  318.  
  319. }
  320.  
  321.  
  322.  
  323. //* Add Default Image for Listings
  324.  
  325. add_filter( 'genesis_get_image', 'agentpress_default_image', 10, 2 );
  326.  
  327. function agentpress_default_image( $output, $args ) {
  328.  
  329. global $post;
  330.  
  331.  
  332.  
  333. if( 'listing' == get_post_type() && ! $output && $args['size'] == 'properties' && $args['format'] == 'html' ) {
  334.  
  335.  
  336.  
  337. $output = sprintf( '<img class="attachment-properties" src="%s" alt="%s" />', get_stylesheet_directory_uri() .'/images/default-listing.png', get_the_title( $post->ID ) );
  338.  
  339.  
  340.  
  341. }
  342.  
  343. return $output;
  344.  
  345. }
  346.  
  347.  
  348.  
  349.  
  350.  
  351.  
  352.  
  353.  
  354.  
  355.  
  356.  
  357. //* Register widget areas
  358.  
  359. genesis_register_sidebar( array(
  360.  
  361. 'id' => 'home-featured',
  362.  
  363. 'name' => __( 'Home - Featured', 'agentpress' ),
  364.  
  365. 'description' => __( 'This is the featured section at the top of the homepage.', 'agentpress' ),
  366.  
  367. ) );
  368.  
  369. genesis_register_sidebar( array(
  370.  
  371. 'id' => 'home-top',
  372.  
  373. 'name' => __( 'Home - Top', 'agentpress' ),
  374.  
  375. 'description' => __( 'This is the top section of the content area on the homepage.', 'agentpress' ),
  376.  
  377. ) );
  378.  
  379. genesis_register_sidebar( array(
  380.  
  381. 'id' => 'home-middle-1',
  382.  
  383. 'name' => __( 'Home - Middle 1', 'agentpress' ),
  384.  
  385. 'description' => __( 'This is first widget-area in the middle section of the content area on the homepage.', 'agentpress' ),
  386.  
  387. ) );
  388.  
  389. genesis_register_sidebar( array(
  390.  
  391. 'id' => 'home-middle-2',
  392.  
  393. 'name' => __( 'Home - Middle 2', 'agentpress' ),
  394.  
  395. 'description' => __( 'This is second widget-area in the middle section of the content area on the homepage.', 'agentpress' ),
  396.  
  397. ) );
  398.  
  399. genesis_register_sidebar( array(
  400.  
  401. 'id' => 'home-middle-3',
  402.  
  403. 'name' => __( 'Home - Middle 3', 'agentpress' ),
  404.  
  405. 'description' => __( 'This is third widget-area in the middle section of the content area on the homepage.', 'agentpress' ),
  406.  
  407. ) );
  408.  
  409. genesis_register_sidebar( array(
  410.  
  411. 'id' => 'home-bottom',
  412.  
  413. 'name' => __( 'Home - Bottom', 'agentpress' ),
  414.  
  415. 'description' => __( 'This is the bottom section of the content area on the homepage.', 'agentpress' ),
  416.  
  417. ) );
  418.  
  419. genesis_register_sidebar( array(
  420.  
  421. 'id' => 'after-entry',
  422.  
  423. 'name' => __( 'After Entry', 'agentpress' ),
  424.  
  425. 'description' => __( 'This is the after entry widget area.', 'agentpress' ),
  426.  
  427. ) );
  428.  
  429. genesis_register_sidebar( array(
  430.  
  431. 'id' => 'listings-archive',
  432.  
  433. 'name' => __( 'Listings Archive', 'agentpress' ),
  434.  
  435. 'description' => __( 'This is the widget-area at the top of the listings archive.', 'agentpress' ),
  436.  
  437. ) );
  438.  
  439. genesis_register_sidebar( array(
  440.  
  441. 'id' => 'disclaimer',
  442.  
  443. 'name' => __( 'Disclaimer', 'agentpress' ),
  444.  
  445. 'description' => __( 'This is the disclaimer section of the footer.', 'agentpress' ),
  446.  
  447. ) );
Advertisement
Add Comment
Please, Sign In to add comment