Skip to content

Commit

Permalink
Merge pull request #1092 from OpenDevelopmentMekong/master
Browse files Browse the repository at this point in the history
merging to prod for releasing v2.3.1
  • Loading branch information
Alex Corbi authored Jul 12, 2017
2 parents 18fae0f + 85d2824 commit 35debdf
Show file tree
Hide file tree
Showing 24 changed files with 760 additions and 241 deletions.
233 changes: 99 additions & 134 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,28 +209,27 @@ function odm_jeo_scripts()
wp_register_script('jquery-ui', 'https://code.jquery.com/ui/1.11.4/jquery-ui.js');
$site_name = odm_country_manager()->get_current_country();

if (is_home()) {
if (is_home()):
wp_enqueue_script('opendev-sticky', get_stylesheet_directory_uri().'/inc/jeo-scripts/sticky-posts.js', array('jeo.markers', 'jquery'), '0.1.2');
}
endif;

if (is_page( array( 'map-explorer', 'embed' )) || is_singular('map') || is_singular('map-layer') || is_singular('profiles') || is_home()){
if ( file_exists( STYLESHEETPATH . '/inc/jeo-scripts/jeo.js')) {
wp_deregister_script('jeo');
wp_enqueue_script('jeo', get_stylesheet_directory_uri() . '/inc/jeo-scripts/jeo.js', array('mapbox-js', 'underscore', 'jquery'), '0.5.0');
}

if ( file_exists( STYLESHEETPATH . '/inc/jeo-scripts/fullscreen.js')){
wp_deregister_script('jeo.fullscreen');
wp_enqueue_script('jeo.fullscreen', get_stylesheet_directory_uri() . '/inc/jeo-scripts/fullscreen.js',array('jeo'), '0.2.0');
}
if ( file_exists( STYLESHEETPATH . '/inc/jeo-scripts/jeo.js')) {
wp_deregister_script('jeo');
wp_enqueue_script('jeo', get_stylesheet_directory_uri() . '/inc/jeo-scripts/jeo.js', array('mapbox-js', 'underscore', 'jquery'), '0.5.0');
}

wp_enqueue_script('BetterWMS', get_stylesheet_directory_uri() . '/inc/jeo-scripts/L.TileLayer.BetterWMS.js', array('jeo', 'jquery'), '1.0.0');
wp_enqueue_script('jeo.clearscreen', get_stylesheet_directory_uri() . '/inc/jeo-scripts/clearscreen.js', array('jeo'), '1.0.0');
wp_enqueue_script('mapping-script', get_stylesheet_directory_uri() . '/inc/jeo-scripts/mapping.js', array('jeo','jquery-ui'), '1.0.0');
wp_enqueue_script('html2canvas', get_stylesheet_directory_uri() . '/inc/html2canvas/html2canvas.js', array('jquery'), '0.34');
wp_enqueue_script('plugin.html2canvas', get_stylesheet_directory_uri() . '/inc/html2canvas/jquery.plugin.html2canvas.js', array('jquery'), '0.33');
wp_enqueue_script('printmap', get_stylesheet_directory_uri() . '/inc/jeo-scripts/printmap.js', array('jeo'), '1.1.0');
if ( file_exists( STYLESHEETPATH . '/inc/jeo-scripts/fullscreen.js')){
wp_deregister_script('jeo.fullscreen');
wp_enqueue_script('jeo.fullscreen', get_stylesheet_directory_uri() . '/inc/jeo-scripts/fullscreen.js',array('jeo'), '0.2.0');
}

wp_enqueue_script('BetterWMS', get_stylesheet_directory_uri() . '/inc/jeo-scripts/L.TileLayer.BetterWMS.js', array('jeo', 'jquery'), '1.0.0');
wp_enqueue_script('jeo.clearscreen', get_stylesheet_directory_uri() . '/inc/jeo-scripts/clearscreen.js', array('jeo'), '1.0.0');
wp_enqueue_script('mapping-script', get_stylesheet_directory_uri() . '/inc/jeo-scripts/mapping.js', array('jeo','jquery-ui'), '1.0.0');
wp_enqueue_script('html2canvas', get_stylesheet_directory_uri() . '/inc/html2canvas/html2canvas.js', array('jquery'), '0.34');
wp_enqueue_script('plugin.html2canvas', get_stylesheet_directory_uri() . '/inc/html2canvas/jquery.plugin.html2canvas.js', array('jquery'), '0.33');
wp_enqueue_script('printmap', get_stylesheet_directory_uri() . '/inc/jeo-scripts/printmap.js', array('jeo'), '1.1.0');
}

if ( file_exists(STYLESHEETPATH . '/inc/jeo-scripts/share-widget.js')) {
Expand Down Expand Up @@ -396,11 +395,11 @@ function odm_category_pre_get_posts($query)

function odm_posts_clauses_join($join)
{
global $wpdb;
if (get_post_type() == 'map' && get_post_type() == 'map-group'){
$join = " INNER JOIN {$wpdb->postmeta} m_maps ON ({$wpdb->posts}.ID = m_maps.post_id) ";
return $join;
}
global $wpdb;
if (get_post_type() == 'map' && get_post_type() == 'map-group'){
$join = " INNER JOIN {$wpdb->postmeta} m_maps ON ({$wpdb->posts}.ID = m_maps.post_id) ";
return $join;
}
}
add_filter('jeo_posts_clauses_join', 'odm_posts_clauses_join');

Expand All @@ -409,60 +408,59 @@ function odm_posts_clauses_where($where)
if (get_post_type() == 'map' && get_post_type() == 'map-group'){
$map_id = jeo_get_map_id();
$where = '';
// MAP
if (get_post_type($map_id) == 'map') {
$where = " AND ( m_maps.meta_key = 'maps' AND CAST(m_maps.meta_value AS CHAR) = '{$map_id}' ) ";

// MAPGROUP
} elseif (get_post_type($map_id) == 'map-group') {
$groupdata = get_post_meta($map_id, 'mapgroup_data', true);
// MAP
if (get_post_type($map_id) == 'map') {
$where = " AND ( m_maps.meta_key = 'maps' AND CAST(m_maps.meta_value AS CHAR) = '{$map_id}' ) ";
// MAPGROUP
} elseif (get_post_type($map_id) == 'map-group') {
$groupdata = get_post_meta($map_id, 'mapgroup_data', true);

if (isset($groupdata['maps']) && is_array($groupdata['maps'])) {
$where = ' AND ( ';
if (isset($groupdata['maps']) && is_array($groupdata['maps'])) {
$where = ' AND ( ';

$size = count($groupdata['maps']);
$i = 1;
$size = count($groupdata['maps']);
$i = 1;

foreach ($groupdata['maps'] as $m) {
$c_map_id = $m['id'];
foreach ($groupdata['maps'] as $m) {
$c_map_id = $m['id'];

$where .= " ( m_maps.meta_key = 'maps' AND CAST(m_maps.meta_value AS CHAR) = '{$c_map_id}' ) ";
$where .= " ( m_maps.meta_key = 'maps' AND CAST(m_maps.meta_value AS CHAR) = '{$c_map_id}' ) ";

if ($i < $size) {
$where .= ' OR ';
}
if ($i < $size) {
$where .= ' OR ';
}

++$i;
}
$where .= ' ) ';
++$i;
}
$where .= ' ) ';
}
}
}
return $where;
}
}
add_filter('jeo_posts_clauses_where', 'odm_posts_clauses_where');

function odm_ignore_sticky($query)
{
if ($query->is_main_query()) {
$query->set('ignore_sticky_posts', true);
}
if ($query->is_main_query()) {
$query->set('ignore_sticky_posts', true);
}
}
add_action('pre_get_posts', 'odm_ignore_sticky');

function my_mce_buttons_2($buttons)
{
array_unshift($buttons, 'fontselect', 'fontsizeselect');
$buttons[] = 'superscript';
$buttons[] = 'subscript';
array_unshift($buttons, 'fontselect', 'fontsizeselect');
$buttons[] = 'superscript';
$buttons[] = 'subscript';

return $buttons;
return $buttons;
}
add_filter('mce_buttons_2', 'my_mce_buttons_2');

function hide_other_country_page_template($pages_templates)
{
return $pages_templates;
return $pages_templates;
}
add_filter('theme_page_templates', 'hide_other_country_page_template');

Expand All @@ -471,10 +469,10 @@ function hide_other_country_page_template($pages_templates)
*****/
function add_iframe($initArray)
{
$initArray['extended_valid_elements'] = 'iframe[id|class|title|style|align|frameborder|height|longdesc|marginheight|marginwidth|name|scrolling|src|width|allowtransparency|allowfullscreen|webkitallowfullscreen|mozallowfullscreen|oallowfullscreen|msallowfullscreen]';
$initArray['extended_valid_elements_div'] = 'div[id|style]';
$initArray['extended_valid_elements'] = 'iframe[id|class|title|style|align|frameborder|height|longdesc|marginheight|marginwidth|name|scrolling|src|width|allowtransparency|allowfullscreen|webkitallowfullscreen|mozallowfullscreen|oallowfullscreen|msallowfullscreen]';
$initArray['extended_valid_elements_div'] = 'div[id|style]';

return $initArray;
return $initArray;
}
// this function alters the way the WordPress editor filters your code
add_filter('tiny_mce_before_init', 'add_iframe');
Expand All @@ -488,110 +486,77 @@ function add_iframe($initArray)
if (!function_exists('tmce_replace')) {
function tmce_replace()
{
$tadv_options = get_option('tadv_options', array());
$tadv_plugins = get_option('tadv_plugins', array());

?>
<script type="text/javascript">
if ( typeof(jQuery) != 'undefined' ) {
jQuery('body').bind('afterPreWpautop', function(e, o){
o.data = o.unfiltered
.replace(/caption\]\ +?<\/object>/g, function(a) {
return a.replace(/[\r\n]+/g, ' ');
});
}).bind('afterWpautop', function(e, o){
o.data = o.unfiltered;
});
}
</script>
$tadv_options = get_option('tadv_options', array());
$tadv_plugins = get_option('tadv_plugins', array());

?>
<script type="text/javascript">
if ( typeof(jQuery) != 'undefined' ) {
jQuery('body').bind('afterPreWpautop', function(e, o){
o.data = o.unfiltered
.replace(/caption\]\ +?<\/object>/g, function(a) {
return a.replace(/[\r\n]+/g, ' ');
});
}).bind('afterWpautop', function(e, o){
o.data = o.unfiltered;
});
}
</script>
<?php

}//end function
add_action('after_wp_tiny_mce', 'tmce_replace');
}
// eof advanced tinymce plugin
// http://tinymce.moxiecode.com/wiki.php/Configuration
function teslina_tinymce_config($init)
{
// Change code cleanup/content filtering config
// Don't remove line breaks
$init['remove_linebreaks'] = false;
// Convert newline characters to BR tags
//$init['convert_newlines_to_brs'] = true;
//$init['force_br_newlines '] = true;

// With this option set to false, the line breaks are stripped from the HTML source.
$init['apply_source_formatting'] = true;
// Preserve tab/space whitespace
$init['preformatted'] = true;
// Do not remove redundant BR tags
$init['remove_redundant_brs'] = false;

return $init;
// Change code cleanup/content filtering config
// Don't remove line breaks
$init['remove_linebreaks'] = false;
// Convert newline characters to BR tags
//$init['convert_newlines_to_brs'] = true;
//$init['force_br_newlines '] = true;

// With this option set to false, the line breaks are stripped from the HTML source.
$init['apply_source_formatting'] = true;
// Preserve tab/space whitespace
$init['preformatted'] = true;
// Do not remove redundant BR tags
$init['remove_redundant_brs'] = false;

return $init;
}
add_filter('tiny_mce_before_init', 'teslina_tinymce_config');

function migrate_tags_to_related() {

ob_start();
include( dirname(__FILE__) . '/admin-scripts/migrate-tags-to-related.php' );
$output = ob_get_contents();
ob_end_clean();
return $output;
ob_start();
include( dirname(__FILE__) . '/admin-scripts/migrate-tags-to-related.php' );
$output = ob_get_contents();
ob_end_clean();
return $output;
}
add_shortcode( 'admin_scripts_migrate_tags_to_related', 'migrate_tags_to_related' );

function convert_keywords_to_related() {

ob_start();
include( dirname(__FILE__) . '/admin-scripts/convert-keywords-to-related.php' );
$output = ob_get_contents();
ob_end_clean();
return $output;
ob_start();
include( dirname(__FILE__) . '/admin-scripts/convert-keywords-to-related.php' );
$output = ob_get_contents();
ob_end_clean();
return $output;
}
add_shortcode( 'admin_scripts_convert_keywords_to_related', 'convert_keywords_to_related' );

function posts_by_category_and_type() {

ob_start();
include( dirname(__FILE__) . '/admin-scripts/posts-by-category-and-type.php' );
$output = ob_get_contents();
ob_end_clean();
return $output;
ob_start();
include( dirname(__FILE__) . '/admin-scripts/posts-by-category-and-type.php' );
$output = ob_get_contents();
ob_end_clean();
return $output;
}
add_shortcode( 'admin_scripts_posts_by_category_and_type', 'posts_by_category_and_type' );

function add_custom_meta_tags() {
global $post;

?>

<!-- ODM -->
<meta name="google-site-verification" content="wSjmxxjHngo-qyApV6i_ACDJ6EgX6bkl1VthAXS0s_I" />
<!-- ODC -->
<meta name="google-site-verification" content="Wj4wmK5q6lq4Rk0x4iqDhuBFaZxfTY2luq9p09Qr2kM" />
<!-- ODMM -->
<meta name="google-site-verification" content="BXhPDDG3ECyUWrdJqbsVr0eba3buOb8XEjV9nudDSk4" />
<!-- ODV -->
<meta name="google-site-verification" content="wSjmxxjHngo-qyApV6i_ACDJ6EgX6bkl1VthAXS0s_I" />
<!-- ODL -->
<meta name="google-site-verification" content="wSjmxxjHngo-qyApV6i_ACDJ6EgX6bkl1VthAXS0s_I" />
<!-- ODT -->
<meta name="google-site-verification" content="wSjmxxjHngo-qyApV6i_ACDJ6EgX6bkl1VthAXS0s_I" />
<?php
if(is_single()) {

?>

<meta property="odm_spatial_range" content="<?php echo odm_country_manager()->get_current_country_code(); ?>"/>
<meta property="odm_language" content="<?php echo odm_language_manager()->get_current_language(); ?>"/>
<meta property="odm_type" content="<?php echo get_post_type(); ?>"/>
<meta property="odm_license" content="CC-BY-SA-4.0"/>

<?php
} else {
return;
}
set_site_meta();
}
add_action('wp_head', 'add_custom_meta_tags', 5);

Expand Down
2 changes: 2 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ var gulp = require('gulp'),

var LESS_PATH = 'less/';
var JS_PATH = 'js/';
var LIB_PATH = 'lib/';
var CSS_PATH = 'css/';
var DEST_PATH = 'dist/'; //Temp path will change later
var CSS_DIST_PATH = DEST_PATH + 'css/';
Expand Down Expand Up @@ -63,4 +64,5 @@ gulp.task('watch', function(){
gulp.watch(LESS_PATH + '/*less', ['build-less', 'build-styles']);
gulp.watch(CSS_PATH + '/*.css', ['build-styles']);
gulp.watch(JS_PATH + '/*.js', ['build-scripts']);
gulp.watch(LIB_PATH + '/js/*.js', ['build-scripts']);
});
26 changes: 1 addition & 25 deletions header.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,7 @@
<?php global $post, $page, $paged; ?>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="<?php bloginfo('charset'); ?>" />
<meta property="og:title" content="<?php the_title(); ?>" />
<meta property="og:description" content="<?php echo odm_excerpt($post); ?>" />
<meta property="og:site_name" content="<?php bloginfo('name'); ?>"/>
<meta property="og:type" content="opendevelopment:<?php echo get_post_type(); ?>" />
<?php if(isset($post) && has_post_thumbnail( $post->ID )) { ?>
<meta property="og:image" content="<?php $img_src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full', false); echo $img_src[0]; ?>" />
<?php } ?>
<meta property="og:url" content="<?php echo get_permalink()?>" />
<title>

<?php
wp_title('|', true, 'right');

bloginfo('name');

$site_description = get_bloginfo('description', 'display');
if ($site_description && (is_home() || is_front_page())) {
echo " | $site_description";
}

if ($paged >= 2 || $page >= 2) {
echo ' | '.__('Page', 'odm').max($paged, $page);
} ?>

</title>
<title><?php set_site_title(); ?></title>
<link rel="profile" href="http://gmpg.org/xfn/11" />
<link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo('stylesheet_url'); ?>" />
<link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
Expand Down
Loading

0 comments on commit 35debdf

Please sign in to comment.