Skip to content

Commit

Permalink
Custom Taxonomies Terms in Ads Zones
Browse files Browse the repository at this point in the history
  • Loading branch information
minimus committed Dec 29, 2013
1 parent 56ee246 commit aa4458f
Show file tree
Hide file tree
Showing 9 changed files with 1,083 additions and 826 deletions.
12 changes: 11 additions & 1 deletion ad.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,7 @@ private function buildZone($args = null, $useCodes = false, $crawler = false) {
sz.z_404,
sz.z_archive,
sz.z_tax,
sz.z_taxes,
sz.z_category,
sz.z_cats,
sz.z_tag,
Expand All @@ -501,6 +502,7 @@ private function buildZone($args = null, $useCodes = false, $crawler = false) {
WHERE $zId AND sz.trash IS FALSE;";
$zone = $wpdb->get_row($zSql, ARRAY_A);
if(!empty($zone)) {
$taxes = unserialize($zone['z_taxes']);
$cats = unserialize($zone['z_cats']);
$authors = unserialize($zone['z_authors']);
$singleCT = unserialize($zone['z_single_ct']);
Expand All @@ -519,6 +521,9 @@ private function buildZone($args = null, $useCodes = false, $crawler = false) {
if((integer)$zone['z_404'] < 0) $zone['z_404'] = $zone['z_default'];
if((integer)$zone['z_archive'] < 0) $zone['z_archive'] = $zone['z_default'];
if((integer)$zone['z_tax'] < 0) $zone['z_tax'] = $zone['z_archive'];
foreach($taxes as $key => $value) {
if($value < 0) $taxes[$key] = $zone['z_tax'];
}
if((integer)$zone['z_category'] < 0) $zone['z_category'] = $zone['z_tax'];
foreach($cats as $key => $value) {
if($value < 0) $cats[$key] = $zone['z_category'];
Expand Down Expand Up @@ -553,7 +558,12 @@ private function buildZone($args = null, $useCodes = false, $crawler = false) {
if(is_404()) $id = $zone['z_404'];
if(is_archive()) {
$id = $zone['z_archive'];
if(is_tax()) $id = $zone['z_tax'];
if(is_tax()) {
$id = $zone['z_tax'];
foreach($taxes as $key => $value) {
if(is_tax($value['tax'], $key)) $id = $value['id'];
}
}
if(is_category()) {
$id = $zone['z_category'];
foreach($cats as $key => $value) {
Expand Down
27 changes: 18 additions & 9 deletions admin.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ public function getTablesDefs() {
'z_404' => array('Type' => "int(11)", 'Null' => 'YES', 'Key' => '', 'Default' => '0', 'Extra' => ''),
'z_archive' => array('Type' => "int(11)", 'Null' => 'YES', 'Key' => '', 'Default' => '0', 'Extra' => ''),
'z_tax' => array('Type' => "int(11)", 'Null' => 'YES', 'Key' => '', 'Default' => '0', 'Extra' => ''),
'z_taxes' => array('Type' => "longtext", 'Null' => 'YES', 'Key' => '', 'Default' => '', 'Extra' => ''),
'z_category' => array('Type' => "int(11)", 'Null' => 'YES', 'Key' => '', 'Default' => '0', 'Extra' => ''),
'z_cats' => array('Type' => "longtext", 'Null' => 'YES', 'Key' => '', 'Default' => '', 'Extra' => ''),
'z_tag' => array('Type' => "int(11)", 'Null' => 'YES', 'Key' => '', 'Default' => '0', 'Extra' => ''),
Expand Down Expand Up @@ -499,7 +500,9 @@ public function finishSettingsTab( $section ) {
}

public function initSettings() {
register_setting('samOptions', SAM_OPTIONS_NAME);
$scStr = __("Shortcode <code>[name]</code> will be replaced with advertiser's name. Shortcode <code>[site]</code> will be replaced with name of your site. Shotcode <code>[month]</code> will be replaced with name of month of reporting period.", SAM_DOMAIN);

register_setting('samOptions', SAM_OPTIONS_NAME);

self::starSettingsTab("sam_general_section", 'tabs-1', __('General', SAM_DOMAIN));
add_settings_section("sam_general_section", __("General Settings", SAM_DOMAIN), array(&$this, "drawGeneralSection"), 'sam-settings');
Expand All @@ -526,7 +529,7 @@ public function initSettings() {

add_settings_field('bpAdsId', __("Ads Place before content", SAM_DOMAIN), array(&$this, 'drawSelectOptionX'), 'sam-settings', 'sam_single_section', array('description' => ''));
add_settings_field('beforePost', __("Allow Ads Place auto inserting before post/page content", SAM_DOMAIN), array(&$this, 'drawCheckboxOption'), 'sam-settings', 'sam_single_section', array('label_for' => 'beforePost', 'checkbox' => true));
add_settings_field('bpExcerpt', __('Allow Ads Place auto inserting before post/page excerpt (in the loop)', SAM_DOMAIN), array(&$this, 'drawCheckboxOption'), 'sam-settings', 'sam_single_section', array('label_for' => 'bpExcerpt', 'checkbox' => true));
add_settings_field('bpExcerpt', __('Allow Ads Place auto inserting before post/page or post/page excerpt in the loop', SAM_DOMAIN), array(&$this, 'drawCheckboxOption'), 'sam-settings', 'sam_single_section', array('label_for' => 'bpExcerpt', 'checkbox' => true));
add_settings_field('bbpBeforePost', __("Allow Ads Place auto inserting before bbPress Forum topic content", SAM_DOMAIN), array(&$this, 'drawCheckboxOption'), 'sam-settings', 'sam_single_section', array('label_for' => 'bbpBeforePost', 'checkbox' => true, 'hide' => self::hideBbpOptions()));
add_settings_field('bbpList', __("Allow Ads Place auto inserting into bbPress Forum forums/topics lists", SAM_DOMAIN), array(&$this, 'drawCheckboxOption'), 'sam-settings', 'sam_single_section', array('label_for' => 'bbpList', 'checkbox' => true, 'hide' => self::hideBbpOptions()));
add_settings_field('bpUseCodes', __("Allow using predefined Ads Place HTML codes (before and after codes)", SAM_DOMAIN), array(&$this, 'drawCheckboxOption'), 'sam-settings', 'sam_single_section', array('label_for' => 'bpUseCodes', 'checkbox' => true));
Expand Down Expand Up @@ -560,11 +563,11 @@ public function initSettings() {

add_settings_field('mailer', __('Allow SAM Mailing System to send statistical data to advertisers', SAM_DOMAIN), array(&$this, 'drawCheckboxOption'), 'sam-settings', 'sam_mailer_section', array('label_for' => 'mailer', 'checkbox' => true));
add_settings_field('mail_subject', __('Mail Subject', SAM_DOMAIN), array(&$this, 'drawTextOption'), 'sam-settings', 'sam_mailer_section', array('description' => __('Mail subject of sending email.', SAM_DOMAIN), 'width' => '70%'));
add_settings_field('mail_greeting', __('Mail Greeting String', SAM_DOMAIN), array(&$this, 'drawTextOption'), 'sam-settings', 'sam_mailer_section', array('description' => __('Greeting string of sending email.', SAM_DOMAIN).' '.__("Shortcode <code>[name]</code> will be replaced with advertiser's name. Shortcode <code>[site]</code> will be replaced with name of your site.", SAM_DOMAIN), 'width' => '70%'));
add_settings_field('mail_text_before', __('Mail Text before statistical data table', SAM_DOMAIN), array(&$this, 'drawTextareaOption'), 'sam-settings', 'sam_mailer_section', array('description' => __('Some text before statistical data table of sending email.', SAM_DOMAIN).' '.__("Shortcode <code>[name]</code> will be replaced with advertiser's name. Shortcode <code>[site]</code> will be replaced with name of your site.", SAM_DOMAIN), 'height' => '75px'));
add_settings_field('mail_text_after', __('Mail Text after statistical data table', SAM_DOMAIN), array(&$this, 'drawTextareaOption'), 'sam-settings', 'sam_mailer_section', array('description' => __('Some text after statistical data table of sending email.', SAM_DOMAIN).' '.__("Shortcode <code>[name]</code> will be replaced with advertiser's name. Shortcode <code>[site]</code> will be replaced with name of your site.", SAM_DOMAIN), 'height' => '75px'));
add_settings_field('mail_warning', __('Mail Warning 1', SAM_DOMAIN), array(&$this, 'drawTextareaOption'), 'sam-settings', 'sam_mailer_section', array('description' => __('This text will be placed at the end of sending email.', SAM_DOMAIN).' '.__("Shortcode <code>[name]</code> will be replaced with advertiser's name. Shortcode <code>[site]</code> will be replaced with name of your site.", SAM_DOMAIN), 'height' => '50px'));
add_settings_field('mail_message', __('Mail Warning 2', SAM_DOMAIN), array(&$this, 'drawTextareaOption'), 'sam-settings', 'sam_mailer_section', array('description' => __('This text will be placed at the very end of sending email.', SAM_DOMAIN).' '.__("Shortcode <code>[name]</code> will be replaced with advertiser's name. Shortcode <code>[site]</code> will be replaced with name of your site.", SAM_DOMAIN), 'height' => '50px'));
add_settings_field('mail_greeting', __('Mail Greeting String', SAM_DOMAIN), array(&$this, 'drawTextOption'), 'sam-settings', 'sam_mailer_section', array('description' => __('Greeting string of sending email.', SAM_DOMAIN).' '.$scStr, 'width' => '70%'));
add_settings_field('mail_text_before', __('Mail Text before statistical data table', SAM_DOMAIN), array(&$this, 'drawTextareaOption'), 'sam-settings', 'sam_mailer_section', array('description' => __('Some text before statistical data table of sending email.', SAM_DOMAIN).' '.$scStr, 'height' => '75px'));
add_settings_field('mail_text_after', __('Mail Text after statistical data table', SAM_DOMAIN), array(&$this, 'drawTextareaOption'), 'sam-settings', 'sam_mailer_section', array('description' => __('Some text after statistical data table of sending email.', SAM_DOMAIN).' '.$scStr, 'height' => '75px'));
add_settings_field('mail_warning', __('Mail Warning 1', SAM_DOMAIN), array(&$this, 'drawTextareaOption'), 'sam-settings', 'sam_mailer_section', array('description' => __('This text will be placed at the end of sending email.', SAM_DOMAIN).' '.$scStr, 'height' => '50px'));
add_settings_field('mail_message', __('Mail Warning 2', SAM_DOMAIN), array(&$this, 'drawTextareaOption'), 'sam-settings', 'sam_mailer_section', array('description' => __('This text will be placed at the very end of sending email.', SAM_DOMAIN).' '.$scStr, 'height' => '50px'));

register_setting('sam-settings', SAM_OPTIONS_NAME, array(&$this, 'sanitizeSettings'));
}
Expand Down Expand Up @@ -1011,6 +1014,7 @@ public function sanitizeSettings($input) {

$output = $input;
$output['dfpBlocks'] = array_unique($blocks);
$output['mailer'] = (isset($input['mailer'])) ? 1 : 0;
return $output;
}

Expand Down Expand Up @@ -1043,8 +1047,13 @@ public function drawDeactivateSection() {
}

public function drawMailerSection() {
$time = get_transient( 'sam_maintenance_date' );
echo "Next mailing is scheduled on <code>{$time}</code>... ".$this->test[0];
$options = parent::getSettings();

if($options['mailer']) {
$time = get_transient( 'sam_maintenance_date' );
echo "<p>".__("Next mailing is scheduled on", SAM_DOMAIN)." <code>{$time}</code>... "."</p>";
}
else echo "<p>".__("Adjust parameters of Mailing System.", SAM_DOMAIN)."</p>";
}

public function drawTextOption( $id, $args ) {
Expand Down
26 changes: 13 additions & 13 deletions css/sam-admin-edit.css
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,20 @@

.sub-content {
padding: 3px 7px;
margin: 0px 5px 0px 15px;
margin: 0 5px 0 15px;
line-height: 140%;
background-color: #EEEEEE;
border-radius: 5px;
-moz-border-radius: 5px 5px 5px 5px;
background-color: #F7F7F7;
border-radius: 3px;
-moz-border-radius: 3px 3px 3px 3px;
}

.sub-content-level-2 {
padding: 3px 7px;
margin: 0px 7px 0px 15px;
margin: 0 7px 0 15px;
line-height: 140%;
background-color: #E0E0E0;
border-radius: 5px;
-moz-border-radius: 5px 5px 5px 5px;
background-color: #F0F0F0;
border-radius: 3px;
-moz-border-radius: 3px 3px 3px 3px;
}

.ad-example {
Expand Down Expand Up @@ -221,11 +221,11 @@ input.button-primary, input.button-secondary,
border: 1px solid #ddd;
border-radius: 3px;
background: #fff;
background: linear-gradient(#f6f6f6 0, #fff 50px);
background: -o-linear-gradient(#f6f6f6 0, #fff 50px);
background: -ms-linear-gradient(#f6f6f6 0, #fff 50px);
background: -moz-linear-gradient(#f6f6f6 0, #fff 50px);
background: -webkit-linear-gradient(#f6f6f6 0, #fff 50px);
background-image: linear-gradient(#f6f6f6 0, #fff 50px);
background-image: -o-linear-gradient(#f6f6f6 0, #fff 50px);
background-image: -ms-linear-gradient(#f6f6f6 0, #fff 50px);
background-image: -moz-linear-gradient(#f6f6f6 0, #fff 50px);
background-image: -webkit-linear-gradient(#f6f6f6 0, #fff 50px);
box-shadow: 0 3px 10px rgba(0,0,0,0.15);
-o-box-shadow: 0 3px 10px rgba(0,0,0,0.1);
-ms-box-shadow: 0 3px 10px rgba(0,0,0,0.1);
Expand Down
4 changes: 4 additions & 0 deletions editor.admin.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,7 @@ public function page() {
</div>
</div>
<div id="tabs-3">
<?php if($action != 'new') { ?>
<p class="totals">
<?php
$now = getdate();
Expand All @@ -608,6 +609,7 @@ public function page() {
<?php _e('Hits', SAM_DOMAIN); ?>: <span id="total_hits"></span><br>
<?php _e('Clicks', SAM_DOMAIN); ?>: <span id="total_clicks"></span><br>
</p>
<?php } ?>
</div>
</div>
<div class="meta-box-sortables ui-sortable">
Expand Down Expand Up @@ -1524,6 +1526,7 @@ public function page() {
</div>
<div id="tabs-5">
<div id="stats" class="meta-box-sortables ui-sortable">
<?php if($action != 'new') { ?>
<p class="totals">
<?php
$now = getdate();
Expand All @@ -1547,6 +1550,7 @@ public function page() {
<?php _e('Hits', SAM_DOMAIN); ?>: <span id="total_hits"></span><br>
<?php _e('Clicks', SAM_DOMAIN); ?>: <span id="total_clicks"></span><br>
</p>
<?php } ?>
</div>
</div>
</div>
Expand Down
Binary file modified langs/simple-ads-manager-ru_RU.mo
Binary file not shown.
Loading

0 comments on commit aa4458f

Please sign in to comment.