| 1 |
<?php |
| 2 |
/** |
| 3 |
* Extension Abstract |
| 4 |
* |
| 5 |
* @package NotificationX\Extensions |
| 6 |
*/ |
| 7 |
|
| 8 |
namespace NotificationX\Types; |
| 9 |
|
| 10 |
use NotificationX\Extensions\GlobalFields; |
| 11 |
use NotificationX\GetInstance; |
| 12 |
use NotificationX\Modules; |
| 13 |
use NotificationX\NotificationX; |
| 14 |
|
| 15 |
/** |
| 16 |
* Extension Abstract for all Extension. |
| 17 |
* @method static Donations get_instance($args = null) |
| 18 |
*/ |
| 19 |
class Donations extends Types { |
| 20 |
/** |
| 21 |
* Instance of Admin |
| 22 |
* |
| 23 |
* @var Admin |
| 24 |
*/ |
| 25 |
use GetInstance; |
| 26 |
|
| 27 |
// donation_themes |
| 28 |
public $priority = 40; |
| 29 |
public $themes = []; |
| 30 |
public $module = ['modules_give']; |
| 31 |
public $default_source = 'give'; |
| 32 |
public $default_theme = 'donation_theme-one'; |
| 33 |
public $link_type = 'donation_page'; |
| 34 |
|
| 35 |
|
| 36 |
/** |
| 37 |
* Initially Invoked when initialized. |
| 38 |
*/ |
| 39 |
public function __construct(){ |
| 40 |
parent::__construct(); |
| 41 |
$this->id = 'donation'; |
| 42 |
} |
| 43 |
|
| 44 |
public function init() { |
| 45 |
parent::init(); |
| 46 |
$this->title = __('Donations', 'notificationx'); |
| 47 |
$common_fields = array( |
| 48 |
'first_param' => 'tag_name', |
| 49 |
'custom_first_param' => __('Someone', 'notificationx'), |
| 50 |
'second_param' => __('recently donated for', 'notificationx'), |
| 51 |
'third_param' => 'tag_none', |
| 52 |
'custom_third_param' => __('100', 'notificationx'), |
| 53 |
'fourth_param' => 'tag_title', |
| 54 |
'custom_fourth_param' => __('Anonymous Title', 'notificationx'), |
| 55 |
'fifth_param' => 'tag_time', |
| 56 |
'custom_fifth_param' => __('Some time ago', 'notificationx'), |
| 57 |
); |
| 58 |
$this->themes = [ |
| 59 |
'theme-one' => [ |
| 60 |
'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/donation/donation-theme-1.jpg', |
| 61 |
'image_shape' => 'circle', |
| 62 |
'template' => $common_fields, |
| 63 |
], |
| 64 |
'theme-two' => [ |
| 65 |
'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/donation/donation-theme-2.jpg', |
| 66 |
'image_shape' => 'circle', |
| 67 |
'template' => $common_fields, |
| 68 |
], |
| 69 |
'theme-three' => [ |
| 70 |
'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/donation/donation-theme-3.jpg', |
| 71 |
'image_shape' => 'square', |
| 72 |
'template' => $common_fields, |
| 73 |
], |
| 74 |
'theme-four' => [ |
| 75 |
'is_pro' => true, |
| 76 |
'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/donation/donation-theme-4.png', |
| 77 |
'image_shape' => 'circle', |
| 78 |
'template' => $common_fields, |
| 79 |
], |
| 80 |
'theme-five' => [ |
| 81 |
'is_pro' => true, |
| 82 |
'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/donation/donation-theme-5.png', |
| 83 |
'image_shape' => 'circle', |
| 84 |
'template' => $common_fields, |
| 85 |
], |
| 86 |
'conv-theme-six' => [ |
| 87 |
'is_pro' => true, |
| 88 |
'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/donation/donation-theme-6.jpg', |
| 89 |
'image_shape' => 'circle', |
| 90 |
], |
| 91 |
'maps_theme' => [ |
| 92 |
'is_pro' => true, |
| 93 |
'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/donation/maps-theme.png', |
| 94 |
'image_shape' => 'square', |
| 95 |
'show_notification_image' => 'maps_image', |
| 96 |
], |
| 97 |
'conv-theme-seven' => [ |
| 98 |
'is_pro' => true, |
| 99 |
'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/donation/donation-theme-7.png', |
| 100 |
'image_shape' => 'rounded', |
| 101 |
], |
| 102 |
'conv-theme-eight' => [ |
| 103 |
'is_pro' => true, |
| 104 |
'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/donation/donation-theme-8.png', |
| 105 |
'image_shape' => 'circle', |
| 106 |
], |
| 107 |
'conv-theme-nine' => [ |
| 108 |
'is_pro' => true, |
| 109 |
'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/donation/donation-theme-9.png', |
| 110 |
'image_shape' => 'square', |
| 111 |
], |
| 112 |
]; |
| 113 |
$this->res_themes = [ |
| 114 |
'res-theme-one' => [ |
| 115 |
'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/res_donation/donation-res-theme-1.png', |
| 116 |
'_template' => 'donation_template_new', |
| 117 |
'is_pro' => true, |
| 118 |
], |
| 119 |
'res-theme-two' => [ |
| 120 |
'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/res_donation/donation-res-theme-2.png', |
| 121 |
'_template' => 'donation_template_new', |
| 122 |
'is_pro' => true, |
| 123 |
], |
| 124 |
'res-theme-three' => [ |
| 125 |
'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/res_donation/donation-res-theme-3.png', |
| 126 |
'_template' => 'donation_template_new', |
| 127 |
'is_pro' => true, |
| 128 |
], |
| 129 |
'res-theme-four' => [ |
| 130 |
'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/res_donation/donation-res-theme-4.png', |
| 131 |
'_template' => 'donation_template_new', |
| 132 |
'is_pro' => true, |
| 133 |
], |
| 134 |
'res-theme-five' => [ |
| 135 |
'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/res_donation/donation-res-theme-5.png', |
| 136 |
'_template' => 'donation_template_new', |
| 137 |
'is_pro' => true, |
| 138 |
], |
| 139 |
'res-theme-six' => [ |
| 140 |
'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/res_donation/donation-res-theme-6.png', |
| 141 |
'_template' => 'donation_template_new', |
| 142 |
'is_pro' => true, |
| 143 |
], |
| 144 |
'res-theme-seven' => [ |
| 145 |
'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/res_donation/donation-res-theme-7.png', |
| 146 |
'_template' => 'maps_template_new', |
| 147 |
'is_pro' => true, |
| 148 |
], |
| 149 |
'res-theme-eight' => [ |
| 150 |
'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/res_donation/donation-res-theme-8.png', |
| 151 |
'_template' => 'donation_template_sales_count', |
| 152 |
'is_pro' => true, |
| 153 |
], |
| 154 |
'res-theme-nine' => [ |
| 155 |
'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/res_donation/donation-res-theme-9.png', |
| 156 |
'_template' => 'donation_template_sales_count', |
| 157 |
'is_pro' => true, |
| 158 |
], |
| 159 |
'res-theme-ten' => [ |
| 160 |
'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/res_donation/donation-res-theme-10.png', |
| 161 |
'_template' => 'donation_template_sales_count', |
| 162 |
'is_pro' => true, |
| 163 |
], |
| 164 |
]; |
| 165 |
$this->templates = [ |
| 166 |
'donation_template_new' => [ |
| 167 |
'first_param' => GlobalFields::get_instance()->common_name_fields(), |
| 168 |
'third_param' => [ // amount_param |
| 169 |
'tag_amount' => __('Donation Amount', 'notificationx'), |
| 170 |
'tag_none' => __('None', 'notificationx'), |
| 171 |
], |
| 172 |
'fourth_param' => [ // third_param |
| 173 |
'tag_title' => __('Donation For Title', 'notificationx'), |
| 174 |
// 'tag_anonymous_title' => __('Anonymous Title', 'notificationx'), |
| 175 |
], |
| 176 |
'fifth_param' => [ // fourth_param |
| 177 |
'tag_time' => __('Definite Time', 'notificationx'), |
| 178 |
// @todo add more options in pro version https://github.com/WPDevelopers/notificationx-pro/blob/440595540e9d3e26e9e2b674921dede7174b22eb/features/class-nxpro-sales-features.php#L290 |
| 179 |
], |
| 180 |
'_themes' => [ |
| 181 |
'donation_theme-one', |
| 182 |
'donation_theme-two', |
| 183 |
'donation_theme-three', |
| 184 |
'donation_theme-four', |
| 185 |
'donation_theme-five', |
| 186 |
'donation_maps_theme', |
| 187 |
], |
| 188 |
], |
| 189 |
'donation_template_sales_count' => [ |
| 190 |
'first_param' => GlobalFields::get_instance()->common_name_fields(), |
| 191 |
'third_param' => [ // third_param |
| 192 |
'tag_title' => __('Donation For Title', 'notificationx'), |
| 193 |
// 'tag_anonymous_title' => __('Anonymous Title', 'notificationx'), |
| 194 |
], |
| 195 |
'fourth_param' => [ // fourth_param |
| 196 |
// @todo add more options in pro version https://github.com/WPDevelopers/notificationx-pro/blob/440595540e9d3e26e9e2b674921dede7174b22eb/features/class-nxpro-sales-features.php#L290 |
| 197 |
], |
| 198 |
'_themes' => [ |
| 199 |
'donation_conv-theme-six', |
| 200 |
'donation_conv-theme-seven', |
| 201 |
'donation_conv-theme-eight', |
| 202 |
'donation_conv-theme-nine', |
| 203 |
], |
| 204 |
], |
| 205 |
]; |
| 206 |
} |
| 207 |
|
| 208 |
/** |
| 209 |
* Hooked to nx_before_metabox_load action. |
| 210 |
* |
| 211 |
* @return void |
| 212 |
*/ |
| 213 |
public function init_fields() { |
| 214 |
parent::init_fields(); |
| 215 |
add_filter('nx_link_types', [$this, 'link_types']); |
| 216 |
} |
| 217 |
|
| 218 |
/** |
| 219 |
* Adds option to Link Type field in Content tab. |
| 220 |
* |
| 221 |
* @param array $options |
| 222 |
* @return array |
| 223 |
*/ |
| 224 |
public function link_types($options) { |
| 225 |
$_options = GlobalFields::get_instance()->normalize_fields([ |
| 226 |
'donation_page' => __('Donation Form Page', 'notificationx'), |
| 227 |
], 'type', $this->id); |
| 228 |
|
| 229 |
return array_merge($options, $_options); |
| 230 |
} |
| 231 |
|
| 232 |
public function preview_entry($entry, $settings){ |
| 233 |
$entry = array_merge($entry, [ |
| 234 |
"title" => "Fundraising Camp for Health", |
| 235 |
|
| 236 |
]); |
| 237 |
return $entry; |
| 238 |
} |
| 239 |
|
| 240 |
} |
| 241 |
|