Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deliverance #68

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
14 changes: 3 additions & 11 deletions .htaccess
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
# force SSL
RewriteCond %{HTTPS} !=on
#

RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteBase /
RewriteBase /candela/
RewriteRule ^index\.php$ - [L]

# add a trailing slash to /wp-admin
Expand All @@ -17,8 +13,4 @@ RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]

</IfModule>

# END WordPress
RewriteRule . index.php [L]
49 changes: 40 additions & 9 deletions wp-content/plugins/candela-outcomes/candela-outcomes.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,20 @@
* GitHub Plugin URI: https://github.com/lumenlearning/candela-outcomes
*/

add_action('admin_init', 'candela_on_admin_init');
namespace Candela\Outcomes;
if( ! defined('CANDELA_OUTCOMES_GUID')){
define('CANDELA_OUTCOMES_GUID', 'CANDELA_OUTCOMES_GUID');
}

add_action('admin_init', '\Candela\Outcomes\candela_on_admin_init');

//Initialize
function candela_on_admin_init() {
if( ! defined('CANDELA_OUTCOMES_GUID')){
define('CANDELA_OUTCOMES_GUID', 'candela_outcomes_guid');
}
$types = array( 'back-matter', 'chapter', 'front-matter',);
foreach($types as $type){
add_meta_box('outcomes',
__('Course Outcomes', 'textdomain'),
'outcomes_metabox_render',
'\Candela\Outcomes\outcomes_metabox_render',
$type,
'normal',
'high'
Expand All @@ -33,7 +34,7 @@ function candela_on_admin_init() {

//Render fields
function outcomes_metabox_render($post) {
$data = get_post_meta($post->ID, 'CANDELA_OUTCOMES_GUID', true);
$data = get_post_meta($post->ID, CANDELA_OUTCOMES_GUID, true);
?>
<div class="inside">
<label for="outcomes_input"><?php _e( "List GUID(s) associated with this content. Separate multiple GUIDs with commas.", 'textdomain' ); ?></label>
Expand All @@ -44,24 +45,54 @@ function outcomes_metabox_render($post) {


//Update metadata when user saves post
add_action('wp_insert_post', 'candela_outcomes_save_meta_value', 10, 2);
add_action('wp_insert_post', '\Candela\Outcomes\candela_outcomes_save_meta_value', 10, 2);

function candela_outcomes_save_meta_value($id) {
if(isset($_POST['my_meta_value']))
$outcomes_input = strtolower($_POST['my_meta_value']);

if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE )
return $id;
if (!current_user_can('edit_posts'))
return;

if(isset($outcomes_input))
$outcomes_input = preg_replace('/([^a-z0-9, :-])/', '', $outcomes_input);

if (!isset($id))
$id = (int) $_REQUEST['post_ID'];

if (isset($outcomes_input)) {
update_post_meta($id, 'CANDELA_OUTCOMES_GUID', $outcomes_input);
update_post_meta($id, CANDELA_OUTCOMES_GUID, $outcomes_input);
} else {
delete_post_meta($id, 'CANDELA_OUTCOMES_GUID');
delete_post_meta($id, CANDELA_OUTCOMES_GUID);
}
}

//Display outcome html
add_action('display_outcome_html', '\Candela\Outcomes\outcome_display_html', 10, 1);

function outcome_display_html($id){
$user_ID = get_current_user_id();
$dataguid = get_post_meta($id, CANDELA_OUTCOMES_GUID);
if(!empty($dataguid)){
?>
<div id='outcome_description' style='display:none'
data-outcome-guids='<?php print(esc_attr($dataguid[0])); ?>'
data-user-id='<?php print($user_ID); ?>'> </div>
<?php
}
}

//Display outcome html
add_action('output_clarity_url', '\Candela\Outcomes\output_clarity_url', 10, 1);

function output_clarity_url(){

if (! empty(CLARITY_ENDPOINT)) {
?>
<div id="clarity_endpoint" style="display: none;"
data-clarity-endpoint="<?php print(esc_attr(CLARITY_ENDPOINT)); ?>"></div>
<?php
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ function fitzgerald_enqueue_styles() {

function cadvanced_enqueue_scripts() {
wp_enqueue_script('foundation', get_stylesheet_directory_uri() . '/js/foundation.min.js');
wp_enqueue_script('deliverance', get_stylesheet_directory_uri() . '/js/deliverance.js', [], '', true);
wp_enqueue_script('deliveryMan', get_stylesheet_directory_uri() . '/js/deliveryMan.js', [], '', true);
}

add_action( 'wp_print_styles', 'fitzgerald_enqueue_styles' );
Expand Down
Loading