PluginProbe
WP MapIt / 1.2
WP MapIt v1.2
3.1.1 trunk 1.0 1.1 1.2 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.7.1 3.0 3.1.0
wp-mapit / wp_mapit / classes / class.wp_mapit_the_content.php

class.wp_mapit_the_content.php in WP MapIt 1.2, at wp_mapit/classes/class.wp_mapit_the_content.php

49 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if( ! class_exists( 'wp_mapit_the_content' ) ) {
4 /**
5 * Class to filter the_content to show map
6 */
7 class wp_mapit_the_content
8 {
9 /**
10 * Add hooks and filters to display map in the content
11 *
12 * @since 1.0
13 * @access public
14 */
15 public static function init() {
16 add_filter( 'the_content', __CLASS__ . '::the_content' );
17 }
18
19 /**
20 * Function to manage the_content filter to display map
21 *
22 * @since 1.0
23 * @access public
24 * @param $content String content of the page
25 * @return String Returns content including the map as string
26 */
27 public static function the_content( $content ){
28
29 /* Check if map is added */
30 if( wp_mapit_map::has_map() ) {
31
32 $mapPosition = wp_mapit_map::get_map_position();
33
34 /* If map is to be displayed before or after content, generate map */
35 if( in_array( $mapPosition, array( 'before', 'after' ) ) ) {
36 $mapContent = wp_mapit_map::generate_map();
37 $content = ( ( $mapPosition == 'before' ) ? ( $mapContent . $content ) : ( $content . $mapContent ) );
38 }
39 }
40
41 return $content;
42 }
43 }
44
45 /**
46 * Calling init function to activate hooks and filters.
47 */
48 wp_mapit_the_content::init();
49 }