From 6b2e6c89e6d66e783e38e72c0b49a56d165dd9d8 Mon Sep 17 00:00:00 2001 From: Simon Maddox Date: Wed, 28 Feb 2018 12:17:16 +0000 Subject: [PATCH] Organisation details Added org details on Opportunity detail page, with setup option to control level of detail --- includes/volplus_Functions.php | 27 ++++++++ .../volplus_Opportunities_List_Shortcode.php | 2 +- .../volplus_Opportunities_List_Widget.php | 3 +- .../volplus_Opportunity_Detail_Shortcode.php | 61 +++++++++++++++++-- includes/volplus_Settings.php | 20 ++++-- wp-volunteer-plus.php | 2 +- 6 files changed, 101 insertions(+), 14 deletions(-) diff --git a/includes/volplus_Functions.php b/includes/volplus_Functions.php index 6e668ad..e5c20a9 100755 --- a/includes/volplus_Functions.php +++ b/includes/volplus_Functions.php @@ -1,5 +1,20 @@ array('Authorization' => 'Bearer '.API_KEY))); + $response_code = wp_remote_retrieve_response_code($organisation); + if($response_code == 200) { + $organisation = json_decode($organisation['body'], true); + return $organisation; + } else { + wp_redirect("/404"); + exit; + } +} + + // get volunteer details given ID - WITH CORRECTIONS function get_volunteer_details($id) { $endpoint = 'volunteers/' . $id; @@ -695,6 +710,18 @@ function ajax_addvolunteer(){ die(); } +//AJAX GET PAGE +add_action('wp_ajax_nopriv_volplus_get_legal', 'volplus_get_legal'); +add_action('wp_ajax_volplus_get_legal', 'volplus_get_legal'); +function volplus_get_page(){ + if(null !==(get_option('volplus_compliancepage'))) { + $output = apply_filters('the_content', get_post_field('post_content', get_option('volplus_compliancepage'))); + echo json_encode($output); + die; + } +} + + //convert dob to age band function dobToAgeBand($age){ $yourage = (int) DateTime::createFromFormat('Y-m-d', $age) diff --git a/includes/volplus_Opportunities_List_Shortcode.php b/includes/volplus_Opportunities_List_Shortcode.php index 037f185..535fc62 100755 --- a/includes/volplus_Opportunities_List_Shortcode.php +++ b/includes/volplus_Opportunities_List_Shortcode.php @@ -19,7 +19,7 @@ function volplus_list_opportunities_func($atts = [], $content = null, $tag = '') $opportunities = wp_remote_get(API_URL . 'opportunities?'.$_SERVER['QUERY_STRING'], array('headers' => array('Authorization' => 'Bearer '.API_KEY))); $response_code = wp_remote_retrieve_response_code($opportunities); $opportunities = json_decode($opportunities['body'], true); - $location = ["","No Location","Working from home","Specific Address","Specific Address","Multiple Specific Addresses","Countrywide","Regional"]; + $location = ["","No Location","Working from home","Specific Address","Specific Address","Multiple Specific Addresses","County-wide","Regional"]; // split query string to array parse_str($_SERVER['QUERY_STRING'],$querystring); diff --git a/includes/volplus_Opportunities_List_Widget.php b/includes/volplus_Opportunities_List_Widget.php index 18e0974..56b50e4 100755 --- a/includes/volplus_Opportunities_List_Widget.php +++ b/includes/volplus_Opportunities_List_Widget.php @@ -30,7 +30,8 @@ public function widget( $args, $instance ) { $response_code = wp_remote_retrieve_response_code($opportunities); $opportunities = json_decode($opportunities['body'], true); -$location = ["","No Location","Working from home","Organisational Address","Specific Address","Multiple Specific Addresses","Countrywide","Regional"]; +$location = ["","No Location","Working from home","Organisational Address","Specific Address","Multiple Specific Addresses","County- +wide","Regional"]; //get_header(); diff --git a/includes/volplus_Opportunity_Detail_Shortcode.php b/includes/volplus_Opportunity_Detail_Shortcode.php index 9b4ab01..0ca3202 100755 --- a/includes/volplus_Opportunity_Detail_Shortcode.php +++ b/includes/volplus_Opportunity_Detail_Shortcode.php @@ -6,6 +6,7 @@ function volplus_opportunity_detail_func($atts) { parse_str($_SERVER['QUERY_STRING'],$querystring); $opp = $querystring['opp-id']; setcookie('volplus_opp_id', $opp, 0, COOKIEPATH, COOKIE_DOMAIN ); +//Fetch opportunity details $opportunity = wp_remote_get(API_URL . 'opportunities/'.$opp, array('headers' => array('Authorization' => 'Bearer '.API_KEY))); $response_code = wp_remote_retrieve_response_code($opportunity); @@ -18,9 +19,12 @@ function volplus_opportunity_detail_func($atts) { wp_redirect("/404"); exit; } + + $organisation = getOrgDetails($opportunity['organisation']['id']); ?> -
+ +

@@ -76,7 +80,52 @@ function volplus_opportunity_detail_func($atts) { -

Posted by

+
+

Organisation

+
+
+ "; + if(null !== $organisation['address_line_2']) echo stripcslashes(html_entity_decode($organisation['address_line_2'])) . "
"; + if(null !== $organisation['address_line_3']) echo stripcslashes(html_entity_decode($organisation['address_line_3'])) . "
"; + if(null !== $organisation['town']) echo stripcslashes(html_entity_decode($organisation['town'])); + if(null !== $organisation['county']) echo ", " . stripcslashes(html_entity_decode($organisation['county'])) . "
"; + if(null !== $organisation['postcode']) echo stripcslashes(html_entity_decode($organisation['postcode'])); + ?> +
+
+ " . $orgStatus[$organisation['status']] . "
"; + if(null !== $organisation['website']) echo "Website: ". stripcslashes(html_entity_decode($organisation['website'])) . "
"; + if(get_option('volplus_hideorgdirect', 'on') !== 'on') { + if(null !== $organisation['telephone_number']) echo "Tel: " . stripcslashes(html_entity_decode($organisation['telephone_number'])) . "
"; + if(null !== $organisation['email_address']) echo "Email: " . stripcslashes(html_entity_decode($organisation['email_address'])) . "
"; + if(null !== $organisation['additional_email_address']) echo "2nd email: " . stripcslashes(html_entity_decode($organisation['additional_email_address'])) . "
"; + } + if(null !== $organisation['charity_registration_number']) echo "Charity number: " . stripcslashes(html_entity_decode($organisation['charity_registration_number'])) . "
"; + if(null !== $organisation['company_registration_number']) echo "Company number: " . stripcslashes(html_entity_decode($organisation['company_registration_number'])) . "
"; + ?> +
+ Organisation Information
"; + echo stripslashes( html_entity_decode($organisation['about'])) . "
"; + } ?> + Mission Statement
"; + echo stripslashes( html_entity_decode($organisation['mission_statement'])) . "
"; + } ?> +
@@ -147,9 +196,9 @@ function volplus_opportunity_detail_func($atts) { case 3: case 4: case 5: if($opportunity['location']['address']) { if(count($opportunity['location']['address']) == 1) { - echo "

Address

"; + echo "

Opportunity Address

"; } else { - echo "

Addresses

"; + echo "

Opportunity Addresses

"; } } foreach($opportunity['location']['address'] as $address) { @@ -319,7 +368,9 @@ function initMap() { - + + + diff --git a/includes/volplus_Settings.php b/includes/volplus_Settings.php index 6a754b0..edfc70d 100755 --- a/includes/volplus_Settings.php +++ b/includes/volplus_Settings.php @@ -69,7 +69,7 @@ function volplus_plugin_settings_page() { Plugin License Code - If you have not received your code contact info@maddox.co.uk + If you have not received your code email info@maddox.co.uk with your Domain name as shown above

Google Maps

@@ -127,16 +127,23 @@ function volplus_plugin_settings_page() { /> Strips out text within brackets in Opportunity titles & Organisation names + + Hide Org Direct Contact fields + /> + Hides telephone & emails from Organisation details + Hide Quality Control item details - /> + /> + Hides 2nd level of details - Volunteer login timeout (hours) - + Volunteer login timeout + + Hour(s). Accepts decimal (e.g. 0.5 for 30mins) - T&C page (checkbox on registration if selected) + T&C page '(Not Used)', @@ -144,7 +151,7 @@ function volplus_plugin_settings_page() { 'name'=> 'volplus_compliancepage' ); wp_dropdown_pages($args);?> - + Shows a mandatory check-box on registration if a page is selected @@ -189,6 +196,7 @@ function volplus_plugin_settings() { register_setting( 'volplus-plugin-settings-group', 'volplus_agebandmsg' ); register_setting( 'volplus-plugin-settings-group', 'volplus_compliancepage' ); register_setting( 'volplus-plugin-settings-group', 'volplus_hidebrackets' ); + register_setting( 'volplus-plugin-settings-group', 'volplus_hideorgdirect' ); register_setting( 'volplus-plugin-settings-group', 'volplus_hideqcdetails' ); register_setting( 'volplus-plugin-settings-group', 'volplus_voltimeout' ); } diff --git a/wp-volunteer-plus.php b/wp-volunteer-plus.php index b0ffc4a..bbe04fd 100755 --- a/wp-volunteer-plus.php +++ b/wp-volunteer-plus.php @@ -3,7 +3,7 @@ * Plugin Name: WP Volunteer Plus * Plugin URI: https://maddox.co.uk/volunteer-plus * Description: A selection of tools for interacting with the Volunteer Plus Database - * Version: 1.0.6 + * Version: 1.0.7 * Author: Simon Maddox * Author URI: https://maddox.co.uk */