Skip to content

Commit

Permalink
Merge pull request #24 from igorbenic/3.0.0
Browse files Browse the repository at this point in the history
3.0.0
  • Loading branch information
igorbenic authored Jul 6, 2019
2 parents 9aeec2d + 6c68338 commit 111123e
Show file tree
Hide file tree
Showing 20 changed files with 1,135 additions and 725 deletions.
137 changes: 52 additions & 85 deletions README.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
=== Plugin Name ===
=== Sponsors ===
Contributors: ibenic
Donate link: https://www.ibenic.com
Donate link: http://www.wpsimplesponsorships.com
Tags: post type, images, partners, sponsors
Requires at least: 3.0.1
Tested up to: 4.9.7
Tested up to: 5.2.2
Requires PHP: 7.0
Stable tag: 2.5.1
Stable tag: 3.0.0
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Sponsors makes it easy to add your sponsors and partners to your WordPress website.

== Description ==

Ever had to add a bunch of images with links on them for your event/company partners? With Sponsors, you won't have to use a text widget for that anymore. The companies and people that support you, your company or your event now get a separate place in the dashboar where you can add a link and an image for each of them. Then you add the Sponsors widget to the sidebar of your choosing and the linked images will show up there.
Ever had to add a bunch of images with links on them for your event/company partners?
With Sponsors, you won't have to use a text widget for that anymore. The companies and people that support you, your company or your event now get a separate place in the dashboar where you can add a link and an image for each of them. Then you add the Sponsors widget to the sidebar of your choosing and the linked images will show up there.

== Installation ==

Expand All @@ -27,109 +28,75 @@ Ever had to add a bunch of images with links on them for your event/company part
1. After you activate the plugin, a new content type will become available on the your WordPress admin panel. Here you can add a link, a description and an image for each Sponsor.
2. Add the widget to one or more sidebars and the images of your sponsors will show up there. Choose from which category you want to display sponsors (or select all), to show or hide images and the description

== Shortcode ==

=== Shortcode ===
== Shortcodes ==

** Sponsors **
The shortcode [sponsors] takes the following options:
* images (yes|no, default: yes)
* image_size (medium|full|thumbnail|large|[any registered image size], default: medium)
* description (yes|no, default: no)
* max (number, default: none, showing all entries)
* title (yes|no, default: no)
* category (category-slug, default: all)
* with_categories (yes|no, default: no )
* category_title ( HTML tag for category title, default: h3)
* size (small|medium|large|full, default: medium)
* style (list|grid, default: list)
* order (ASC|DESC, default: ASC )
* orderby (menu_order|post_title|..., default: menu_order)

== Changelog ==

= 2.5.1 =
* Fixed a PHP 7.2 deprecation error

= 2.5.0 =
* Fixed a small error and the plugin now works with Gutenburg!

= 2.4.1 =
* Fixed php errors when using the shortcode without any options

= 2.4.0 =
* Better responsive styling for the shortcode grid
* Moved all fields to a single metabox in the admin dashboard

= 2.3.3 =
* Fixed syntax errors in upgrade script for 2.0
* Added link behaviour settings to shortcode
When with_categories is used, it will show sponsors under their appropriate categories.
The attribute size is used to define the size of the columns. More style updates will come in future versions.

= 2.3.2 =
* Sort by menu_order by default in the shortcode
** Form **
This shortcode will display a form so potential sponsors can submit their information.
Each Sponsor entered with that form will become a Draft so they won't be displayed immediately.
You can publish them, or send them an email to get their logo as well.

= 2.3.1 =
* Fixed a critical issue where we assumed your table prefix was 'wp_'
* Fixed the max settings in the shortcode
Shortcode [sponsors_acquisition_form] will allow it. Fields that are used here are:

= 2.3.0 =
* Fixed equal height grid layout for the shortcode
* Added a per-sponsor setting to open the sponsor link in a new window
* Name
* Email (so you can email them about their submission)
* Description
* Link

= 2.2.3 =
* Fixes an issue where the shortcode would take over the current page's post type and edit link.
== Planned Features ==

= 2.2.2 =
* Changed how sponsors are links in the shortcode. No using the no-images option, the title will be linked and the description won't be. With images, the image will link and the title won't.
Here are some of the features planned for future versions:

= 2.2.1 =
* Bugfix
* Form Block - for the new WordPress block editor
* Sponsors Block - for the new WordPress block editor
* Category ordering
* Documentation Page
* Front optimizations
* Elementor Blocks

= 2.2 =
* Added translations for fr_BE and fr_FR
* Added a filter called "sponsors_widget_styling" to add a css class to each sponsor item from your theme
== Upgrade Notice ==

= 2.1 =
* Added number of entries and title options to the shortcode
* Added number of entries option to the widget
* Added orderby title and random options to the widget
= 3.0.0 =
3.0.0 is a big update. Make a full site backup.

= 2.0.3 =
* Fixed a problem where the sponsor link wouldn't be shown when using no images in the shortcode

= 2.0.2 =
* The "no images" options in the shortcode now actually works
* Improved styling of the widget title across themes
* Updated translations for nl_NL and nl_BE

= 2.0.1 =
* Fixes a PHP notice when installing the plugin for the first time

= 2.0.0 =
* The plugin now uses the featured image field to save the sponsor's logo
* Improved shortcode code and added "grid" style option
* Added debug option to shortcode to better support layout issues

= 1.9.1 =
* Bugfix in the nofollow feature

= 1.9.0 =
* Improved sponsor description saving
* Added default rel="nofollow" for sponsor links
* Added support and donate links to plugin description

= 1.8.5 =
* In the shortcode, items are now sorted by the menu_order by default.
== Changelog ==

= 1.8.4 =
* PHP 7 Compatibilty
* Fixes a bug with the category selection in the shortcode, props to joachimjusth
= 3.0.0 =
* Big Code refactor.
* Refactor: URL is stored under _website. Backwards compatibility is available.
* Refactor: Description is stored under the regular content so we don't waste the database space.
* Refactor: Post Type has changed from 'sponsor' to 'sponsors'.
* Refactor: CSS for horizontal widget display has been enabled.
* New: Image sizes can be defined in shortcode and in widget.
* New: Sponsors can be display under appropriate categories in shortcode.
* New: Sponsor Acquisition Form shortcode [sponsors_acquisition_form] for front end information submission.
* New: Simple Sponsorships compatibility.

= 1.8.3 =
* One last fix to the category selection in the widget, this should have all cases possible now.
= 2.5.1 =
* Fixed a PHP 7.2 deprecation error

= 1.8.2 =
* Fixes a bug caused in 1.8.1 where widgets that selected all sponsor categories wouldn't display any entries.
= 2.5.0 =
* Fixed a small error and the plugin now works with Gutenburg!

= 1.8.1 =
* Fixes a problem with category filtering on the widget
= 2.4.1 =
* Fixed php errors when using the shortcode without any options

= 1.8.0 =
* Added "show sponsor title" option to the widget, not checked by default
* Updated the translations files with the latest strings and included an updatedd nl_NL translation

More information of older versions can be found in changelog.txt
106 changes: 104 additions & 2 deletions admin/class-wp-sponsors-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
42 changes: 42 additions & 0 deletions admin/partials/meta-boxes/sponsor-info.php
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>';
12 changes: 12 additions & 0 deletions admin/partials/meta-boxes/ss-info.php
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>';
Loading

0 comments on commit 111123e

Please sign in to comment.