-
Notifications
You must be signed in to change notification settings - Fork 6
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 #24 from igorbenic/3.0.0
3.0.0
- Loading branch information
Showing
20 changed files
with
1,135 additions
and
725 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -20,7 +20,7 @@ | |
* @subpackage Wp_Sponsors/admin | ||
* @author Jan Henckens <[email protected]> | ||
*/ | ||
class Wp_Sponsors_Admin { | ||
class WP_Sponsors_Admin { | ||
|
||
/** | ||
* The ID of this plugin. | ||
|
@@ -104,7 +104,109 @@ public function enqueue_scripts() { | |
|
||
} | ||
|
||
/** | ||
/** | ||
* Save Metaboxes. | ||
* | ||
* @param $post_id | ||
*/ | ||
public function save_meta_boxes( $post_id ) { | ||
// verify this came from the our screen and with proper authorization, | ||
// because save_post can be triggered at other times | ||
|
||
// Checks save status | ||
$is_autosave = wp_is_post_autosave( $post_id ); | ||
$is_revision = wp_is_post_revision( $post_id ); | ||
$is_valid_nonce = ( isset( $_POST['wp_sponsors_nonce'] ) && wp_verify_nonce( $_POST['wp_sponsors_nonce'], basename( __FILE__ ) ) ) ? 'true' : 'false'; | ||
// Exits script depending on save status | ||
if ( $is_autosave || $is_revision || ! $is_valid_nonce ) { | ||
return; | ||
} | ||
// Checks for input and sanitizes/saves if needed | ||
if ( isset( $_POST['_website'] ) ) { | ||
update_post_meta( $post_id, '_website', sanitize_text_field( $_POST['_website'] ) ); | ||
} | ||
|
||
if ( isset( $_POST['_email'] ) ) { | ||
update_post_meta( $post_id, '_email', sanitize_text_field( $_POST['_email'] ) ); | ||
} | ||
|
||
if ( isset( $_POST['wp_sponsors_desc'] ) ) { | ||
update_post_meta( $post_id, 'wp_sponsors_desc', $_POST['wp_sponsors_desc'] ); | ||
} | ||
|
||
$link_behaviour = isset($_POST['wp_sponsor_link_behaviour']) ? '1' : '0'; | ||
update_post_meta( $post_id, 'wp_sponsor_link_behaviour', $link_behaviour ); | ||
} | ||
|
||
/** | ||
* Sponsors metaboxes | ||
*/ | ||
public function add_meta_boxes() { | ||
add_meta_box( 'wp-sponsor-info', __( 'Sponsor', 'wp_sponsors' ), array( $this, 'sponsors_info_metabox' ), 'sponsors', 'normal', 'high' ); | ||
remove_meta_box( 'postimagediv', 'sponsors', 'side' ); //replace post_type from your post type name | ||
add_meta_box( 'postimagediv', __( 'Sponsor logo', 'wp-sponsors' ), 'post_thumbnail_meta_box', 'sponsors', 'side', 'high' ); | ||
if ( ! class_exists('\Simple_Sponsorships\Plugin' ) ) { | ||
add_meta_box( 'ss-metabox-info', __( 'Simple Sponsorships', 'wp-sponsors' ), array( $this, 'ss_info_metabox' ), 'sponsors', 'side', 'low' ); | ||
} | ||
} | ||
|
||
public function sponsors_info_metabox( $post ) { | ||
include_once 'partials/meta-boxes/sponsor-info.php'; | ||
} | ||
|
||
public function ss_info_metabox() { | ||
include_once 'partials/meta-boxes/ss-info.php'; | ||
} | ||
|
||
|
||
/** | ||
* Adds a new column to the Sponsors overview list in the dashboard | ||
* | ||
* @param array $defaults | ||
*/ | ||
public function add_new_sponsors_column( $defaults ) { | ||
$defaults['wp_sponsors_logo'] = __( 'Sponsor logo', 'wp-sponsors' ); | ||
$defaults['menu_order'] = __( 'Order', 'wp-sponsors' ); | ||
|
||
return $defaults; | ||
} | ||
|
||
/** | ||
* Adds the sponsors image (if available) to the Sponsors overview list in the dashboard | ||
* | ||
* @param string $column_name | ||
* @param integer $post_id | ||
*/ | ||
public function sponsors_custom_columns( $column_name, $post_id ) { | ||
global $post; | ||
|
||
switch ( $column_name ) { | ||
case 'wp_sponsors_logo': | ||
echo get_the_post_thumbnail( $post_id, array( 0, 50 ) ); | ||
break; | ||
case 'menu_order': | ||
$order = $post->menu_order; | ||
echo $order; | ||
break; | ||
default: | ||
break; | ||
} | ||
} | ||
|
||
/** | ||
* Order Column | ||
* | ||
* @param $columns | ||
* | ||
* @return mixed | ||
*/ | ||
public function sponsor_order_column( $columns ) { | ||
$columns['menu_order'] = 'menu_order'; | ||
|
||
return $columns; | ||
} | ||
|
||
/** | ||
* The function that checks for updates and runs the appropriate upgrade when needed | ||
* | ||
* @since 2.0.0 | ||
|
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,42 @@ | ||
<?php | ||
|
||
// Display code/markup goes here. Don't forget to include nonces! | ||
// Noncename needed to verify where the data originated | ||
echo '<input type="hidden" name="wp_sponsors_nonce" id="wp_sponsors_nonce" value="' . wp_create_nonce( plugin_basename( __FILE__ ) ) . '" />'; | ||
// Get the url data if its already been entered | ||
$meta_value = get_post_meta( get_the_ID(), '_website', true ); | ||
if ( ! $meta_value ) { | ||
$meta_value = get_post_meta( get_the_ID(), 'wp_sponsors_url', true ); | ||
} | ||
// Checks and displays the retrieved value | ||
echo '<p class="post-attributes-label-wrapper"><label for="wp_sponsors_url" class="post-attributes-label">' . __( 'Link', 'wp-sponsors' ) . '</label></p>'; | ||
echo '<input type="url" name="_website" value="' . $meta_value . '" class="widefat" />'; | ||
|
||
|
||
// Get the url data if its already been entered | ||
$meta_value = get_post_meta( get_the_ID(), '_email', true ); | ||
// Checks and displays the retrieved value | ||
echo '<p class="post-attributes-label-wrapper"><label for="wp_sponosrs_email" class="post-attributes-label">' . __( 'Email', 'wp-sponsors' ) . '</label></p>'; | ||
echo '<input type="email" id="wp_sponosrs_email" name="_email" value="' . $meta_value . '" class="widefat" />'; | ||
|
||
|
||
// Display code/markup goes here. Don't forget to include nonces! | ||
// Noncename needed to verify where the data originated | ||
// Get the url data if its already been entered | ||
$meta_value = get_post_meta( get_the_ID(), 'wp_sponsors_desc', true ); | ||
$meta_value = apply_filters( 'the_content', $meta_value ); | ||
$meta_value = str_replace( ']]>', ']]>', $meta_value ); | ||
// Checks and displays the retrieved value | ||
$editor_settings = array( 'wpautop' => true, | ||
'media_buttons' => false, | ||
'textarea_rows' => '8', | ||
'textarea_name' => 'wp_sponsors_desc' | ||
); | ||
echo '<p class="post-attributes-label-wrapper"><label for="wp_sponsors_desc" class="post-attributes-label">' . __( 'Description', 'wp-sponsors' ) . '</label></p>'; | ||
echo '<p><strong>Description field will be deleted in 3.1.0. Please move all the content in the default content area above (if it did not move automatically).</strong></p>'; | ||
echo wp_editor( $meta_value, 'wp_sponsors_desc', $editor_settings ); | ||
|
||
$meta_value = get_post_meta( get_the_ID(), 'wp_sponsor_link_behaviour', true ); | ||
echo '<p class="post-attributes-label-wrapper"><label for="wp_sponsor_link_behaviour" class="post-attributes-label">' . __( 'Link behaviour', 'wp-sponsors' ) . '</label></p>'; | ||
$meta_value = $meta_value == "" ? "1" : $meta_value; | ||
echo '<label><input type="checkbox" id="wp_sponsor_link_behaviour" name="wp_sponsor_link_behaviour" value="1" ' . checked( $meta_value, '1', false ) . '>' . __( 'Open link in a new window', 'wp-sponsors' ) . '</label>'; |
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,12 @@ | ||
<?php | ||
|
||
echo '<p>' . __( 'A complete solution for managing Sponsors.', 'wp-sponsors' ) . '</p>'; | ||
echo '<p>' . __( 'With Simple Sponsorships you can:', 'wp-sponsors' ) . '</p>'; | ||
echo '<ul style="padding-left: 1.5em;list-style-type: circle">'; | ||
echo '<li>' . __( 'Automate Sponsor Requests', 'wp-sponsors' ) . '</li>'; | ||
echo '<li>' . __( 'Accept Payments', 'wp-sponsors' ) . '</li>'; | ||
echo '<li>' . __( 'Display Packages', 'wp-sponsors' ) . '</li>'; | ||
echo '<li>' . __( 'Display Sponsors on any page with shortcode/block or under the appropriate content.', 'wp-sponsors' ) . '</li>'; | ||
echo '</ul>'; | ||
echo '<p><em>' . __( 'Compatible with Sponsors', 'wp-sponsors' ) . '</em></p>'; | ||
echo '<a target="_blank" class="button button-primary" href="https://wordpress.org/plugins/simple-sponsorships/">' . __( 'Check the free version', 'wp-sponsors' ) . '</a>'; |
Oops, something went wrong.