Example #1
0
    /** Generate the output for the metabox **/
    function gfb_customizer_box()
    {
        ?>
		<div class="gfb-outer">
		<div class="gfb-inner gfb-brand">
			<table class="gfb-layout">
			<tr>
				<td colspan="3">
				<h4><?php 
        _e('Brand Name', 'genesis-footer-builder');
        ?>
</h4>
				<p><span class="gfb-desc"><?php 
        _e('Enter brand name that will show up in footer credits. Site title is used by default.', 'genesis-footer-builder');
        ?>
</span></p>
				</td>
			</tr>
			<tr>
				<td class="field-label">
				<p><label for="<?php 
        $this->field_id('gfb_brand');
        ?>
"><?php 
        _e('Brand Name: ', 'genesis-footer-builder');
        ?>
</label></p>
				</td>
				<td>
				<p><input type="text" name="<?php 
        $this->field_name('gfb_brand');
        ?>
" id="<?php 
        $this->field_id('gfb_brand');
        ?>
" value="<?php 
        echo esc_attr($this->get_field_value('gfb_brand'));
        ?>
" /></p>
				</td>
			</tr>
			</table>
		</div>
		
		<div class="gfb-inner gfb-duration">
			<table class="gfb-layout">
			<tr>
				<td colspan="3">
				<h4><?php 
        _e('Copyright Duration ', 'genesis-footer-builder');
        ?>
</h4>
				<p class="gfb-desc"><?php 
        _e('Please select a custom year for copyright notice. Current year is used by default. You can also specify the from - to years by checking the from - to box below. Years valid from 19** to 20**.', 'genesis-footer-builder');
        ?>
</p>
				</td>
			</tr>
			<tr>
				<td class="field-label">
				<p><label for="<?php 
        $this->field_id('gfb_current_date');
        ?>
"><?php 
        _e('Use current year?', 'genesis-footer-builder');
        ?>
</label></p>
				</td>
				<td>
				<p><input type="checkbox" name="<?php 
        $this->field_name('gfb_current_date');
        ?>
" id="<?php 
        $this->field_id('gfb_current_date');
        ?>
" value="1"<?php 
        checked($this->get_field_value('gfb_current_date'));
        ?>
 /></p>
				</td>
				</tr>
			</table>
			<div id="gfb-custom-date">
				<div id="gfb-date-format-unset">
					<table class="gfb-layout">
					<tr>
						<td class="field-label">
						<p><label for="<?php 
        $this->field_id('gfb_date');
        ?>
"><?php 
        _e('Enter the year: ', 'genesis-footer-builder');
        ?>
</label></p>
						</td>
						<td>
						<p><input type="number"  name="<?php 
        $this->field_name('gfb_date');
        ?>
" id="<?php 
        $this->field_id('gfb_date');
        ?>
" maxlength="4" size="4" value="<?php 
        echo esc_attr($this->get_field_value('gfb_date'));
        ?>
" /></p>
						</td>
					</tr>
					</table>
				</div>
			
				<div id="gfb-date-format-set">
					<table class="gfb-layout">
					<tr>
						<td class="field-label">
						<p><label for="<?php 
        $this->field_id('gfb_date');
        ?>
"><?php 
        _e('Enter the year(s): ', 'genesis-footer-builder');
        ?>
</label></p>
						</td>
						<td>
						<p><input type="number" name="<?php 
        $this->field_name('gfb_date_start');
        ?>
" id="<?php 
        $this->field_id('gfb_date_start');
        ?>
" value="<?php 
        echo esc_attr($this->get_field_value('gfb_date_start'));
        ?>
" />
						&mdash;
						<input type="number" name="<?php 
        $this->field_name('gfb_date_end');
        ?>
" id="<?php 
        $this->field_id('gfb_date_end');
        ?>
" value="<?php 
        echo esc_attr($this->get_field_value('gfb_date_end'));
        ?>
" /></p>
						</td>
					</tr>
					</table>
				</div>
				
				<table class="gfb-layout">
				<tr>
					<td class="field-label">
					<p><label for="<?php 
        $this->field_id('gfb_date_format');
        ?>
"><?php 
        printf(__('Use %sfrom - to%s format? ', 'genesis-footer-builder'), '<em>', '</em>');
        ?>
</label></p>
					</td>
					<td>
					<p><input type="checkbox" name="<?php 
        $this->field_name('gfb_date_format');
        ?>
" id="<?php 
        $this->field_id('gfb_date_format');
        ?>
" value="1"<?php 
        checked($this->get_field_value('gfb_date_format'));
        ?>
 /></p>
					</td>
				</tr>
				</table>
			</div>
		</div>
		
		<div class="gfb-inner gfb-privacy">
			<table class="gfb-layout">
			<tr>
				<td colspan="3">
				<h4><?php 
        _e('Privacy Policy Page', 'genesis-footer-builder');
        ?>
</h4>
				<p class="gfb-desc"><?php 
        _e('Select a page below to be used as the Privacy Policy page in the footer information.', 'genesis-footer-builder');
        ?>
</p>
				</td>
			</tr>
			<tr>
				<?php 
        $invalid_pg = get_pages(array('post_status' => 'trash, draft, pending'));
        ?>
				<td class="field-label">
				<p><label for="<?php 
        $this->field_id('gfb_privacy');
        ?>
"><?php 
        _e('Select a page: ', 'genesis-footer-builder');
        ?>
</label></p>
				</td>
				<td>
				<p><?php 
        wp_dropdown_pages(array('selected' => $this->get_field_value('gfb_privacy'), 'name' => $this->get_field_name('gfb_privacy'), 'exclude' => $invalid_pg, 'show_option_none' => sprintf(__('%1$s Select %1$s', 'genesis-footer-builder'), '&mdash;')));
        ?>
</p>
				</td>
			</tr>
			</table>
		</div>
		
		<div class="gfb-inner gfb-disclaimer">
			<table class="gfb-layout">
			<tr>
				<td colspan="3">
				<h4><?php 
        _e('Disclaimer Page', 'genesis-footer-builder');
        ?>
</h4>
				<p class="gfb-desc"><?php 
        _e('Select a page below to be used as the Disclaimer page in the footer information.', 'genesis-footer-builder');
        ?>
</p>
				</td>
			</tr>
			<tr>
				<td class="field-label">
				<p><label for="<?php 
        $this->field_id('gfb_disclaimer');
        ?>
"><?php 
        _e('Select a page: ', 'genesis-footer-builder');
        ?>
</label></p>
				</td>
				<td>
				<p><?php 
        wp_dropdown_pages(array('selected' => $this->get_field_value('gfb_disclaimer'), 'name' => $this->get_field_name('gfb_disclaimer'), 'exclude' => $invalid_pg, 'show_option_none' => __('&mdash; Select &mdash;', 'genesis-footer-builder')));
        ?>
</p>
				</td>
			</tr>
			</table>
		</div>
		
		<div class="gfb-inner gfb-fmenu">
			<table class="gfb-layout">
			<tr>
				<td colspan="3">
				<h4><?php 
        _e('Footer Menu', 'genesis-footer-builder');
        ?>
</h4>
				<p class="gfb-desc"><?php 
        printf(__('With this option enabled, Genesis Footer Builder allows you to set-up a footer menu and output it in the footer. This can come handy if you want to insert some useful links like Home, About Us, Contact Us, Sitemap etc. Enable this option and save the settings. Then you can go to %sMenus page%s, create a new menu or select an existing menu and assign %s location.', 'genesis-footer-builder'), '<a href="' . esc_url(admin_url('nav-menus.php')) . '">', '</a>', genesis_code('Genesis Footer Builder Menu'));
        ?>
</p>
				<p class="gfb-desc"><?php 
        _e('*Note: Only the first level menu-items will be displayed.', 'genesis-footer-builder');
        ?>
</p>
				</td>
			</tr>
			<tr>
				<td class="field-label">
				<p><label for="<?php 
        $this->field_id('gfb_footer_menu');
        ?>
"><?php 
        _e('Register and insert Footer Menu? ', 'genesis-footer-builder');
        ?>
</label></p>
				</td>
				<td>
				<p><input type="checkbox" name="<?php 
        $this->field_name('gfb_footer_menu');
        ?>
" id="<?php 
        $this->field_id('gfb_footer_menu');
        ?>
" value="1"<?php 
        checked($this->get_field_value('gfb_footer_menu'));
        ?>
 /></p>
				</td>
			</tr>
			</table>
		</div>
		
		<div class="gfb-inner gfb-fmenu">
			<table class="gfb-layout">
			<tr>
				<td colspan="3">
				<h4><?php 
        _e('Genesis Affiliate Link', 'genesis-footer-builder');
        ?>
</h4>
				<p class="gfb-desc"><?php 
        _e('Use this option to set your own Genesis affiliate link in the footer credits text.', 'genesis-footer-builder');
        ?>
</p>
				</td>
			</tr>
			<tr>
				<td class="field-label">
				<p><label for="<?php 
        $this->field_id('gfb_affiliate_link');
        ?>
"><?php 
        _e('Enter the Genesis affiliate link:', 'genesis-footer-builder');
        ?>
</label></p>
				</td>
				<td>
				<input type="text" name="<?php 
        $this->field_name('gfb_affiliate_link');
        ?>
" id="<?php 
        $this->field_id('gfb_affiliate_link');
        ?>
" value="<?php 
        echo esc_attr($this->get_field_value('gfb_affiliate_link'));
        ?>
" />
				</td>
			</tr>
			</table>
		</div>
		
		<div class="gfb-inner gfb-custom-copy">
			<?php 
        $default_copyright = gfb_customized_footer($this->get_field_value('gfb_output'));
        ?>
			<table class="gfb-layout">
			<tr>
				<td colspan="3">
				<h4><?php 
        _e('Custom Footer Copyrights', 'genesis-footer-builder');
        ?>
</h4>
				<p class="gfb-desc"><?php 
        printf(__('You can build your own custom credits text below. This field allows you to use HTML tags, entities, Genesis footer shortcodes or any other shortcodes. Additionally, the plugin provides the following shortcodes to customize the output:%1$sDisplays the value of %7$sBrand Name%8$s option as set above.%2$sDisplays the value of %7$sCopyright Duration%8$s option as set above.%3$sDisplays the selected page as set in %7$sPrivacy Policy page%8$s option above. Text for the link can be customized using the %9$stext%10$s attribute.%4$sDisplays the selected page as set in <em>Disclaimer page</em> option above. Text for the link can be customized using the %9$stext%10$s attribute.%5$sDisplays the Genesis affiliate link as set in the %7$sGenesis Affiliate Link%8$s option above.%6$s', 'genesis-footer-builder'), '</p><dl class="gfb-def-list"><dt>' . genesis_code('[gfb-brand]') . ':</dt><dd>', '</dd><br /><dt>' . genesis_code('[gfb-date]') . ':</dt><dd>', '</dd><br /><dt>' . genesis_code('[gfb-privacy-policy text="Privacy Policy"]') . ':</dt><dd>', '</dd><br /><dt>' . genesis_code('[gfb-disclaimer text="Disclaimer"]') . ':</dt><dd>', '</dd><br /><dt>' . genesis_code('[gfb-affiliate-link]') . ':</dt><dd>', '</dd><br /></dl>', '<em>', '</em>', '<strong>', '</strong>');
        ?>
				</td>
			</tr>
			<tr>
				<td colspan="3">
				<p><textarea name="<?php 
        $this->field_name('gfb_output');
        ?>
" id="<?php 
        $this->field_id('gfb_output');
        ?>
" rows="3" style="width: 100%;"><?php 
        echo esc_textarea($this->get_field_value('gfb_output'));
        ?>
</textarea></p>
				</td>
			</tr>
			<?php 
        $default_output = gfb_defaults();
        $default_output = $default_output['gfb_output'];
        $footer_output = gfb_customized_footer($this->get_field_value('gfb_output'));
        if (!gfb_get_option('gfb_output')) {
            ?>
					<tr>
						<td colspan="3">
						<div class="gfb-highlight gfb-example"><?php 
            printf(__('%sUsage Example:%s', 'genesis-footer-builder'), '<strong>', '</strong><div class="gfb-example">' . htmlentities($default_output) . '</div>');
            ?>
</div>
						</td>
					</tr>
			<?php 
        } else {
            ?>
					<tr>
						<td colspan="3">
						<div class="gfb-highlight"><?php 
            printf(__('%sPreview:%s', 'genesis-footer-builder'), '<strong>', '</strong><br /> ' . do_shortcode($footer_output));
            ?>
</div>
						</td>
					</tr>
			<?php 
        }
        ?>
			</table>
		</div>
		</div>
		<?php 
    }
/** 
 *  The main function that outputs the customized text through the 'genesis_footer_output' filter.
 */
function gfb_customized_footer($genesis_output)
{
    $output = gfb_get_option('gfb_output');
    $date = '[gfb-date]';
    $brand = '[gfb-brand]';
    $privacy = '[gfb-privacy-policy]';
    $disclaimer = '[gfb-disclaimer]';
    $affil_link = '[gfb-affiliate-link]';
    $privacy_set = gfb_get_option('gfb_privacy');
    $disclaimer_set = gfb_get_option('gfb_disclaimer');
    /** Retrieve the plugin's default credits text **/
    $default_output = gfb_defaults();
    $default_output = $default_output['gfb_output'];
    /** The output has not been customized. Make sure there are no double separators between empty settings. **/
    if (strcmp($default_output, $output) === 0) {
        if (!$privacy_set && !$disclaimer_set) {
            $genesis_output = '<p>' . sprintf(__('Copyright %s %s All rights reserved.', 'genesis-footer-builder'), '&copy; ' . $date, '&mdash;' . $brand . ' &bull;') . '</p><p>[gfb-affiliate-link] &bull; [footer_wordpress_link] &bull; [footer_loginout]</p>';
        } else {
            if (!$disclaimer_set) {
                $genesis_output = '<p>' . sprintf(__('Copyright %s %s All rights reserved. %s', 'genesis-footer-builder'), '&copy; ' . $date . ' &mdash;', $brand . ' &bull;', '&bull; ' . $privacy) . '</p><p>[gfb-affiliate-link] &bull; [footer_wordpress_link] &bull; [footer_loginout]</p>';
            } else {
                if (!$privacy_set) {
                    $genesis_output = '<p>' . sprintf(__('Copyright %s %s All rights reserved. %s', 'genesis-footer-builder'), '&copy; ' . $date . ' &mdash;', $brand . ' &bull;', '&bull; ' . $disclaimer) . '</p><p>[gfb-affiliate-link] &bull; [footer_wordpress_link] &bull; [footer_loginout]</p>';
                } else {
                    $genesis_output = '<p>' . sprintf(__('Copyright %s %s All rights reserved. %s %s', 'genesis-footer-builder'), '&copy; ' . $date . ' &mdash;', $brand . ' &bull;', '&bull; ' . $privacy, '&bull; ' . $disclaimer) . '</p><p>[gfb-affiliate-link] &bull; [footer_wordpress_link] &bull; [footer_loginout]<p>';
                }
            }
        }
    } else {
        /** The output has been customized. Output as is **/
        return do_shortcode($output);
    }
    return do_shortcode($genesis_output);
}