. */ /* shortcodes: [affiliate-disclosure-statement] Used to display the disclosure statement in a page. */ // content filter add_filter('the_content', 'affiliate_disclosure_statement_filter', 99); // content filter function affiliate_disclosure_statement_filter($content) { // get the affiliate disclosure document $disclosure = nl2br(file_get_contents(dirname(__FILE__).'/affiliate-disclosure-statement.txt')); // load options if( ($website = get_option('affiliate_disclosure_website')) === FALSE ) $website = ''; if( ($affiliate_programs = get_option('affiliate_disclosure_programs')) === FALSE ) $affiliate_programs = ''; $attribution = get_option('affiliate_disclosure_attribution'); // replace website values $disclosure = preg_replace('/\[website\]/', $website, $disclosure); // replace affiliate programs values $disclosure = preg_replace('/\[affiliate programs\]/', $affiliate_programs, $disclosure); // replace the shortcode in the content $content = preg_replace('/\[affiliate-disclosure-statement\]/', $disclosure, $content); // show attribution if set if( $attribution ) { $content .= '
Provided by Website Builder.
'; } return $content; } // if an admin is loading the admin menu then call the admin actions function if( is_admin() ) add_action('admin_menu', 'affiliate_disclosure_admin_actions'); // actions to perform when the admin menu is loaded function affiliate_disclosure_admin_actions() { add_options_page("Affiliate Disclosure", "AffiliateDisclosure", 1, "AffiliateDisclosure", "affiliate_disclosure_admin"); } // function called when Disclosure is selected from the admin menu function affiliate_disclosure_admin() { include('affiliate-disclosure-statement-options.php'); } ?>