Skip to content

Commit

Permalink
Merge pull request #1 from navnorth/stage
Browse files Browse the repository at this point in the history
Merge fixes and updates on stage to main
  • Loading branch information
johnpaulbalagolan authored Sep 16, 2021
2 parents dca016f + d61c661 commit 3da240c
Show file tree
Hide file tree
Showing 50 changed files with 2,979 additions and 16,228 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Deploy to WordPress.org
on:
push:
tags:
- "*"

workflow_dispatch:
jobs:
tag:
name: New tag
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Build # Remove or modify this step as needed
run: |
npm install
npm run build
- name: WordPress Plugin Deploy
uses: 10up/action-wordpress-plugin-deploy@stable
env:
SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }}
SVN_USERNAME: ${{ secrets.SVN_USERNAME }}
SLUG: open-educational-resources
12 changes: 6 additions & 6 deletions classes/class-standards-importer.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,18 @@ function download_standard($url){
if(!file_exists($path))
{
mkdir($path, 0777, true);
debug_log("WAS : create samples directory");
was_debug_log("WAS : create samples directory");
}

if(!file_exists($file = $path.$filename))
{
debug_log("WAS : start downloading ". $url ." to local");
was_debug_log("WAS : start downloading ". $url ." to local");

$fp = fopen($file,'wb');
fwrite($fp, $raw);
fclose($fp);

debug_log("WAS : end of download");
was_debug_log("WAS : end of download");
}
return $file;
}
Expand All @@ -59,7 +59,7 @@ function import_standard($file, $other = false){
set_time_limit(0);

// Log start of import process
debug_log("Academic Standards Importer: Start Bulk Import of Standards");
was_debug_log("Academic Standards Importer: Start Bulk Import of Standards");

if( isset($file) )
{
Expand Down Expand Up @@ -200,11 +200,11 @@ function import_standard($file, $other = false){
'type' => 'error'
);
// Log any error during import process
debug_log($e->getMessage());
was_debug_log($e->getMessage());
return $response;
}
// Log Finished Import
debug_log("Academic Standards Importer: Finished Bulk Import of Standards");
was_debug_log("Academic Standards Importer: Finished Bulk Import of Standards");

// save other title or url
if ($other==true){
Expand Down
10 changes: 7 additions & 3 deletions css/admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,6 @@ tr.hide-title-setting td { padding:0 10px 15px !important; }
text-align: center;
background: rgba(60,60,60,0.5);
display:none;
margin-left: -20px;
padding-right: 20px;
}
.loader .loader-img { display: table; overflow: hidden; height:100%; width:100%; }
.loader .loader-img div { display:table-cell; top:30%; position:relative; }
Expand Down Expand Up @@ -304,4 +302,10 @@ label.was-core-standard{
.standard-heading-inline { margin-bottom:15px; }
.was_stndrd_desc { display:inline-block; }
li.oer_sbstndard input[type=checkbox] { margin-top:0; margin-right:8px; }
li.oer_sbstndard > .oer_stndrd_desc { display:inline; margin-left:0; }
li.oer_sbstndard > .oer_stndrd_desc { display:inline; margin-left:0; }
li.was_sbstndard a {cursor:pointer;}
li.was_sbstndard a.nochild {
color: unset;
text-decoration: unset;
cursor: unset;
}
84 changes: 42 additions & 42 deletions includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
global $wpdb;

/** Check Child Standard Notation **/
if (!function_exists('check_child_standard')) {
function check_child_standard($id)
if (!function_exists('was_check_child_standard')) {
function was_check_child_standard($id)
{
global $wpdb;
$results = $wpdb->get_results( $wpdb->prepare( "SELECT * from " . $wpdb->prefix. "oer_standard_notation where parent_id = %s" , $id ) , ARRAY_A);
Expand All @@ -12,8 +12,8 @@ function check_child_standard($id)
}

/** Get Substandard Children **/
if (!function_exists('get_substandard_children')){
function get_substandard_children($id)
if (!function_exists('was_get_substandard_children')){
function was_get_substandard_children($id)
{
global $wpdb;
$results = $wpdb->get_results( $wpdb->prepare( "SELECT * from " . $wpdb->prefix. "oer_sub_standards where parent_id = %s" , $id ) , ARRAY_A);
Expand All @@ -22,8 +22,8 @@ function get_substandard_children($id)
}

// Get Title or Description of Standard or Notation
if (!function_exists('get_standard_label')) {
function get_standard_label($slug){
if (!function_exists('was_get_standard_label')) {
function was_get_standard_label($slug){
global $wpdb;

$slugs = explode("-", $slug);
Expand All @@ -43,8 +43,8 @@ function get_standard_label($slug){
}

/** Get Sub Standard **/
if (!function_exists('child_standards')){
function child_standards($id, $display=false)
if (!function_exists('was_children_standards')){
function was_children_standards($id, $display=false)
{
global $wpdb, $chck, $class;
$collapse = " class='collapse'";
Expand All @@ -66,8 +66,8 @@ function child_standards($id, $display=false)
$value = 'sub_standards-'.$result['id'];

$id = 'sub_standards-'.$result['id'];
$subchildren = get_substandard_children($id);
$child = check_child_standard($id);
$subchildren = was_get_substandard_children($id);
$child = was_check_child_standard($id);

if ($index==1){
$hiddenUp = "hidden-block";
Expand All @@ -84,21 +84,21 @@ function child_standards($id, $display=false)
}

if(empty($subchildren) && empty($child)) {
echo stripslashes($result['standard_title']);
echo "<a class='nochild' data-toggle='collapse' data-target='#".$id.",#".$id."-1'>".stripslashes($result['standard_title'])."</a>";
echo '<span class="std-up std-icon '.$hiddenUp.'"><a href="#"><i class="fas fa-arrow-up"></i></a></span><span class="std-down std-icon '.$hiddenDown.'"><a href="#"><i class="fas fa-arrow-down"></i></a></span> <span class="std-edit"><a class="std-edit-icon" data-target="#editStandardModal" data-value="'.$id.'" data-stdid="'.$result['id'].'"><i class="far fa-edit"></i></a></span> <span class="std-add"><a data-target="#addStandardModal" class="std-add-icon" data-parent="'.$id.'"><i class="fas fa-plus"></i></a></span>';
}

$id = 'sub_standards-'.$result['id'];
child_standards($id);
was_children_standards($id);

if (empty($subchildren) && !empty($child)) {
echo "<a data-toggle='collapse' data-target='#".$id.",#".$id."-1'>".stripslashes($result['standard_title'])."</a>";
echo '<span class="std-up std-icon '.$hiddenUp.'"><a href="#"><i class="fas fa-arrow-up"></i></a></span><span class="std-down std-icon '.$hiddenDown.'"><a href="#"><i class="fas fa-arrow-down"></i></a></span> <span class="std-edit"><a class="std-edit-icon" data-target="#editStandardModal" data-value="'.$id.'" data-stdid="'.$result['id'].'"><i class="far fa-edit"></i></a></span> <span class="std-add"><a data-target="#addStandardModal" class="std-add-icon" data-parent="'.$id.'"><i class="fas fa-plus"></i></a></span>';
$sid = 'sub_standards-'.$result['id'];
child_standard_notations($sid);
was_children_standard_notations($sid);
} elseif (!empty($subchildren) && !empty($child)) {
$sid = 'sub_standards-'.$result['id'];
child_standard_notations($sid, true);
was_children_standard_notations($sid, true);
}
echo "</li>";
$index++;
Expand All @@ -110,8 +110,8 @@ function child_standards($id, $display=false)
}

/** Get Standard Notation **/
if (!function_exists('child_standard_notations')) {
function child_standard_notations($id, $continue = false)
if (!function_exists('was_children_standard_notations')) {
function was_children_standard_notations($id, $continue = false)
{
global $wpdb, $class;

Expand All @@ -131,7 +131,7 @@ function child_standard_notations($id, $continue = false)
$hiddenUp = "";
$hiddenDown = "";
$id = 'standard_notation-'.$result['id'];
$child = check_child_standard($id);
$child = was_check_child_standard($id);
$value = 'standard_notation-'.$result['id'];

if ($index==1){
Expand All @@ -155,7 +155,7 @@ function child_standard_notations($id, $continue = false)
echo '<span class="std-up std-icon '.$hiddenUp.'"><a href="#"><i class="fas fa-arrow-up"></i></a></span><span class="std-down std-icon '.$hiddenDown.'"><a href="#"><i class="fas fa-arrow-down"></i></a></span> <span class="std-edit std-icon"><a data-target="#editStandardModal" data-value="'.$id.'" data-stdid="'.$result['id'].'"><i class="far fa-edit"></i></a></span> <span class="std-add std-icon"><a data-target="#addStandardModal" class="std-add-icon" data-parent="'.$id.'"><i class="fas fa-plus"></i></a></span><span class="std-del std-icon"><a class="std-del-icon" data-stdid="'.$result['id'].'" data-value="'.$id.'"><i class="far fa-trash-alt"></i></a></span>';
echo "</li>";

child_standard_notations($id);
was_children_standard_notations($id);
$index++;
}
echo "</ul>";
Expand Down Expand Up @@ -190,7 +190,7 @@ function was_display_admin_standards(){
<span class="std-add std-icon"><a data-target="#addStandardModal" class="std-add-icon" data-parent="<?php echo $value; ?>"><i class="fas fa-plus"></i></a></span>
</li>
<?php
child_standards($value);
was_children_standards($value);
}
?>
</ul>
Expand All @@ -212,7 +212,7 @@ function was_display_admin_core_standards(){
$value = 'core_standards-'.$row['id'];
?>
<li class='core-standard'>
<a href="<?php echo admin_url("admin.php?page=wp-academic-standards&std=core_standards-".$row['id']); ?>" data-toggle='collapse' data-id="<?php echo $row['id']; ?>" data-target='#core_standards-<?php echo $row['id']; ?>'><?php echo stripslashes(esc_html($row['standard_name'])); ?></a>
<a href="<?php echo admin_url("admin.php?page=wp-academic-standards&std=core_standards-".$row['id']); ?>" data-id="<?php echo $row['id']; ?>"><?php echo stripslashes(esc_html($row['standard_name'])); ?></a>
<span class="std-edit std-icon"><a data-target="#editStandardModal" class="std-edit-icon" data-value="<?php echo $value; ?>" data-stdid="<?php echo $row['id']; ?>"><i class="far fa-edit"></i></a></span>
</li>
<?php
Expand Down Expand Up @@ -253,7 +253,7 @@ function was_selectable_admin_standards($post_id, $meta_key="oer_standard"){
function was_child_standards($id, $oer_standard, $meta_key="oer_standard") {
global $wpdb, $chck, $class;

$results = $wpdb->get_results( $wpdb->prepare( "SELECT * from " . $wpdb->prefix. "oer_sub_standards where parent_id = %s" , $id ) ,ARRAY_A);
$results = $wpdb->get_results( $wpdb->prepare( "SELECT * from " . $wpdb->prefix. "oer_sub_standards where parent_id = %s ORDER by pos, id" , $id ) ,ARRAY_A);
if(!empty($oer_standard))
{
$stndrd_arr = explode(",",$oer_standard);
Expand Down Expand Up @@ -281,8 +281,8 @@ function was_child_standards($id, $oer_standard, $meta_key="oer_standard") {
}

$id = 'sub_standards-'.$result['id'];
$subchildren = get_substandard_children($id);
$child = check_child_standard($id);
$subchildren = was_get_substandard_children($id);
$child = was_check_child_standard($id);

echo "<li class='oer_sbstndard ". $class ."'>";

Expand Down Expand Up @@ -333,7 +333,7 @@ function was_child_standard_notations($id, $oer_standard, $meta_key="oer_standar
$chck = '';
$class = '';
$id = 'standard_notation-'.$result['id'];
$child = check_child_standard($id);
$child = was_check_child_standard($id);
$value = 'standard_notation-'.$result['id'];

if(!empty($oer_standard))
Expand Down Expand Up @@ -902,7 +902,7 @@ function was_show_setup_settings() {
</div>
</div>
<div class="was-plugin-row">
<form method="post" class="was_settings_form" action="options.php" onsubmit="return wasShowLoader(this)">
<form method="post" class="was_settings_form" action="options.php" onsubmit="return was_ShowLoader(this)">
<?php settings_fields("was_setup_settings"); ?>
<?php do_settings_sections("standards-settings"); ?>
<?php submit_button('Save', 'primary setup-continue'); ?>
Expand Down Expand Up @@ -968,7 +968,7 @@ function was_importStandards($file){
set_time_limit(0);

// Log start of import process
debug_log("Academic Standards Importer: Start Bulk Import of Standards");
was_debug_log("Academic Standards Importer: Start Bulk Import of Standards");

if( isset($file) ){
try {
Expand Down Expand Up @@ -1106,11 +1106,11 @@ function was_importStandards($file){
'type' => 'error'
);
// Log any error during import process
debug_log($e->getMessage());
was_debug_log($e->getMessage());
return $response;
}
// Log Finished Import
debug_log("Academic Standards Importer: Finished Bulk Import of Standards");
was_debug_log("Academic Standards Importer: Finished Bulk Import of Standards");
// Get Standard Notation
$response = array(
'message' => 'successful',
Expand Down Expand Up @@ -1415,8 +1415,8 @@ function was_admin_delete_substandards($parent_id){
$value = 'sub_standards-'.$sub['id'];

$id = 'sub_standards-'.$sub['id'];
$subchildren = get_substandard_children($id);
$child = check_child_standard($id);
$subchildren = was_get_substandard_children($id);
$child = was_check_child_standard($id);

if (!empty($subchildren))
was_admin_delete_substandards($id);
Expand Down Expand Up @@ -1445,7 +1445,7 @@ function was_admin_delete_standard_notations($parent_id){
foreach($results as $result)
{
$id = 'standard_notation-'.$result['id'];
$child = check_child_standard($id);
$child = was_check_child_standard($id);
$value = 'standard_notation-'.$result['id'];

if ($child)
Expand Down Expand Up @@ -1476,18 +1476,18 @@ function was_search_imported_standards($imported_standards, $standard){
}
}

if (!function_exists('debug_log')){
if (!function_exists('was_debug_log')){
// Log Debugging
function debug_log($message) {
function was_debug_log($message) {
error_log($message);
}
}

/**
* Get Core Standard by Notation
**/
if (!function_exists('oer_std_get_standard_by_notation')){
function oer_std_get_standard_by_notation($notation){
if (!function_exists('was_oer_std_get_standard_by_notation')){
function was_oer_std_get_standard_by_notation($notation){
global $wpdb;

$std = null;
Expand All @@ -1500,14 +1500,14 @@ function oer_std_get_standard_by_notation($notation){

if ($standard_notation){
$substandard_id = $standard_notation[0]->parent_id;
$substandard = oer_std_get_parent_standard($substandard_id);
$substandard = was_oer_std_get_parent_standard($substandard_id);

if (strpos($substandard[0]['parent_id'],"core_standards")!==false){
$pIds = explode("-",$substandard[0]['parent_id']);

if (count($pIds)>1){
$parent_id=(int)$pIds[1];
$std = oer_std_get_standard_by_id($parent_id);
$std = was_oer_std_get_standard_by_id($parent_id);
}
}
}
Expand All @@ -1517,8 +1517,8 @@ function oer_std_get_standard_by_notation($notation){
}

/** Get Parent Standard **/
if (!function_exists('oer_std_get_parent_standard')) {
function oer_std_get_parent_standard($standard_id) {
if (!function_exists('was_oer_std_get_parent_standard')) {
function was_oer_std_get_parent_standard($standard_id) {
global $wpdb, $_oer_prefix;

$stds = explode("-",$standard_id);
Expand All @@ -1539,7 +1539,7 @@ function oer_std_get_parent_standard($standard_id) {
$tbls = array('sub_standards','standard_notation');

if (in_array($tbl,$tbls)){
$results = oer_std_get_parent_standard($result['parent_id']);
$results = was_oer_std_get_parent_standard($result['parent_id']);
}

}
Expand All @@ -1550,8 +1550,8 @@ function oer_std_get_parent_standard($standard_id) {
/**
* Get Standard By Id
**/
if (!function_exists('oer_std_get_standard_by_id')){
function oer_std_get_standard_by_id($id){
if (!function_exists('was_oer_std_get_standard_by_id')){
function was_oer_std_get_standard_by_id($id){
global $wpdb;

$std = null;
Expand Down
Loading

0 comments on commit 3da240c

Please sign in to comment.