forked from winkm89/teachPress
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from winkm89/master
Merge upstream changes.
- Loading branch information
Showing
13 changed files
with
286 additions
and
47 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<?php | ||
/** | ||
* The award object class | ||
* @since 9.0.0 | ||
*/ | ||
class TP_Award { | ||
protected $pub_awards = array(); | ||
|
||
/** | ||
* Register a page | ||
* | ||
* @param array $atts { | ||
* @type string $award_slug The internal key fo the award | ||
* @type string $i18n_singular The singular label for the award | ||
* @type string $i18n_plural The plural label for the award | ||
* } | ||
*/ | ||
public function register($atts){ | ||
// define defaults | ||
$param = shortcode_atts(array( | ||
'award_slug' => '', | ||
'i18n_singular' => '', | ||
'i18n_plural' => '', | ||
'icon' => '' | ||
), $atts); | ||
|
||
if ( $param['award_slug'] !== '' ) { | ||
$this->pub_awards[ $param['award_slug'] ] = array( | ||
'award_slug' => $param['award_slug'], | ||
'i18n_singular' => $param['i18n_singular'], | ||
'i18n_plural' => $param['i18n_plural'], | ||
'icon' => $param['icon'] | ||
); | ||
} | ||
} | ||
|
||
/** | ||
* Returns all registered pages as array | ||
* @return array | ||
*/ | ||
public function get() { | ||
return $this->pub_awards; | ||
} | ||
|
||
/** | ||
* Returns the page data by the given award_slug | ||
* @param string $award_slug | ||
* @return array | ||
*/ | ||
public function get_data($award_slug) { | ||
if ( isset( $this->pub_awards[$award_slug] ) ) { | ||
return $this->pub_awards[$award_slug]; | ||
} | ||
return null; | ||
} | ||
} | ||
|
||
/** | ||
* Registers a award | ||
* @global type $tp_awards | ||
* @param array $atts | ||
* @since 9.0.0 | ||
*/ | ||
function tp_register_award($atts) { | ||
global $tp_awards; | ||
|
||
// Instance the object if it's not done yet | ||
if ( ! ( $tp_awards instanceof TP_Award ) ) { | ||
$tp_awards = new TP_Award(); | ||
} | ||
|
||
$tp_awards->register($atts); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
/** | ||
* Registers all default awards | ||
* @since 9.0.0 | ||
*/ | ||
function tp_register_all_awards() { | ||
// No Award | ||
tp_register_award( | ||
array( | ||
'award_slug' => 'none', | ||
'i18n_singular' => __('None','teachpress'), | ||
'i18n_plural' => __('None','teachpress'), | ||
'icon' => '' | ||
) ); | ||
|
||
// Best Paper | ||
tp_register_award( | ||
array( | ||
'award_slug' => 'best', | ||
'i18n_singular' => __('Best Paper','teachpress'), | ||
'i18n_plural' => __('Best Papers','teachpress'), | ||
'icon' => 'fas fa-trophy' | ||
) ); | ||
|
||
// Honorable Mention | ||
tp_register_award( | ||
array( | ||
'award_slug' => 'honorable', | ||
'i18n_singular' => __('Honorable Mention','teachpress'), | ||
'i18n_plural' => __('Honorable Mentions','teachpress'), | ||
'icon' => 'fas fa-award' | ||
) ); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters