Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/ninja-fo.../includes
File: PromotionManager.php
<?php if ( ! defined( 'ABSPATH' ) ) exit;
[0] Fix | Delete
[1] Fix | Delete
class NF_PromotionManager
[2] Fix | Delete
{
[3] Fix | Delete
[4] Fix | Delete
public $promotions;
[5] Fix | Delete
[6] Fix | Delete
/**
[7] Fix | Delete
* Accepts a string of location to tell let us know where in the app we are sending promotions to.
[8] Fix | Delete
* Then will return an array of promotions to run in the location.
[9] Fix | Delete
*/
[10] Fix | Delete
public function __construct()
[11] Fix | Delete
{
[12] Fix | Delete
$this->set_promotions();
[13] Fix | Delete
$this->maybe_remove_personal();
[14] Fix | Delete
$this->maybe_remove_sendwp();
[15] Fix | Delete
$this->sort_active_promotions_by_locations();
[16] Fix | Delete
}
[17] Fix | Delete
[18] Fix | Delete
public function get_promotions()
[19] Fix | Delete
{
[20] Fix | Delete
return $this->promotions;
[21] Fix | Delete
}
[22] Fix | Delete
[23] Fix | Delete
/**
[24] Fix | Delete
* Set our promtions array to our promotions property.
[25] Fix | Delete
*/
[26] Fix | Delete
private function set_promotions()
[27] Fix | Delete
{
[28] Fix | Delete
if ( apply_filters( 'ninja_forms_disable_marketing', false ) )
[29] Fix | Delete
{
[30] Fix | Delete
$this->promotions = array();
[31] Fix | Delete
} else {
[32] Fix | Delete
$this->promotions = Ninja_Forms()->config( 'DashboardPromotions' );
[33] Fix | Delete
}
[34] Fix | Delete
}
[35] Fix | Delete
[36] Fix | Delete
/**************************************************************************
[37] Fix | Delete
* Membership Checks
[38] Fix | Delete
*
[39] Fix | Delete
* These funcitons all check to see if the individual add-ons that make up
[40] Fix | Delete
* our personal membership are active.
[41] Fix | Delete
****************************************************************************/
[42] Fix | Delete
private function is_layout_styles_active()
[43] Fix | Delete
{
[44] Fix | Delete
return class_exists( 'NF_Layouts', false );
[45] Fix | Delete
}
[46] Fix | Delete
[47] Fix | Delete
private function is_conditional_logic_active()
[48] Fix | Delete
{
[49] Fix | Delete
return class_exists( 'NF_ConditionalLogic', false );
[50] Fix | Delete
}
[51] Fix | Delete
[52] Fix | Delete
private function is_multi_part_active()
[53] Fix | Delete
{
[54] Fix | Delete
return class_exists( 'NF_MultiPart', false );
[55] Fix | Delete
}
[56] Fix | Delete
[57] Fix | Delete
private function is_file_uploads_active()
[58] Fix | Delete
{
[59] Fix | Delete
return class_exists( 'NF_FU_File_Uploads', false );
[60] Fix | Delete
}
[61] Fix | Delete
[62] Fix | Delete
/**
[63] Fix | Delete
* Utilizes the helper methods above to determine if a
[64] Fix | Delete
* a Membership is active on a site.
[65] Fix | Delete
*/
[66] Fix | Delete
private function is_personal_active()
[67] Fix | Delete
{
[68] Fix | Delete
if( $this->is_conditional_logic_active() && $this->is_file_uploads_active() &&
[69] Fix | Delete
$this->is_layout_styles_active() && $this->is_multi_part_active() ) {
[70] Fix | Delete
return true;
[71] Fix | Delete
}
[72] Fix | Delete
return false;
[73] Fix | Delete
}
[74] Fix | Delete
[75] Fix | Delete
/**************************************************************************
[76] Fix | Delete
* Promotion Removal Methods
[77] Fix | Delete
*
[78] Fix | Delete
* These funcitons all check for different add-ons/products and remove
[79] Fix | Delete
* promotions for them if they are in use.
[80] Fix | Delete
****************************************************************************/
[81] Fix | Delete
private function maybe_remove_sendwp()
[82] Fix | Delete
{
[83] Fix | Delete
if( phpversion() < '5.6.0' ) {
[84] Fix | Delete
$this->remove_promotion( 'sendwp' );
[85] Fix | Delete
return;
[86] Fix | Delete
} if( $this->is_sendwp_active() ) {
[87] Fix | Delete
$this->remove_promotion( 'sendwp' );
[88] Fix | Delete
} elseif( $this->is_ninja_mail_active() ) {
[89] Fix | Delete
$this->remove_promotion( 'sendwp' );
[90] Fix | Delete
}
[91] Fix | Delete
}
[92] Fix | Delete
[93] Fix | Delete
private function maybe_remove_personal()
[94] Fix | Delete
{
[95] Fix | Delete
if( $this->is_personal_active() ) {
[96] Fix | Delete
$this->remove_promotion( 'personal' );
[97] Fix | Delete
}
[98] Fix | Delete
}
[99] Fix | Delete
[100] Fix | Delete
/***************************************************************************
[101] Fix | Delete
* Helper Methods
[102] Fix | Delete
****************************************************************************/
[103] Fix | Delete
/**
[104] Fix | Delete
* Pass in a promotion type to have it removed from
[105] Fix | Delete
* the list of active promotions.
[106] Fix | Delete
*
[107] Fix | Delete
* @return void
[108] Fix | Delete
*/
[109] Fix | Delete
private function remove_promotion( $type )
[110] Fix | Delete
{
[111] Fix | Delete
// Loops over promotions and removes unused types of promotions.
[112] Fix | Delete
foreach( $this->promotions as $promotion ) {
[113] Fix | Delete
if( $type == $promotion[ 'type' ] ) {
[114] Fix | Delete
unset( $this->promotions[ $promotion[ 'id' ] ] );
[115] Fix | Delete
}
[116] Fix | Delete
}
[117] Fix | Delete
}
[118] Fix | Delete
[119] Fix | Delete
/**
[120] Fix | Delete
* Sorts our promotions by where they will appear in app.
[121] Fix | Delete
*
[122] Fix | Delete
* @return void
[123] Fix | Delete
*/
[124] Fix | Delete
private function sort_active_promotions_by_locations()
[125] Fix | Delete
{
[126] Fix | Delete
$sorted_locations = array();
[127] Fix | Delete
foreach( $this->promotions as $promotion ) {
[128] Fix | Delete
$sorted_locations[ $promotion[ 'location' ] ][] = $promotion;
[129] Fix | Delete
}
[130] Fix | Delete
$this->promotions = $sorted_locations;
[131] Fix | Delete
}
[132] Fix | Delete
[133] Fix | Delete
private function is_sendwp_active()
[134] Fix | Delete
{
[135] Fix | Delete
if( class_exists( '\SendWP\Mailer', FALSE ) ) {
[136] Fix | Delete
return true;
[137] Fix | Delete
}
[138] Fix | Delete
return false;
[139] Fix | Delete
}
[140] Fix | Delete
[141] Fix | Delete
private function is_ninja_mail_active()
[142] Fix | Delete
{
[143] Fix | Delete
if( class_exists('\NinjaMail\Plugin', FALSE ) ) {
[144] Fix | Delete
return true;
[145] Fix | Delete
}
[146] Fix | Delete
return false;
[147] Fix | Delete
}
[148] Fix | Delete
}
[149] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function