コード例 #1
0
/**
* Returns the contents of an option file
**/
function wp_get_option($option)
{
    $dirchk = checkdir();
    if ($dirchk == false) {
        return false;
    } elseif ($dirchk == true) {
        if (file_exists(WIPIOPTSPATH . "/{$option}.wp")) {
            if (!wp_option_isempty($option)) {
                return file_get_contents(WIPIOPTSPATH . "/{$option}.wp");
            } else {
                return true;
            }
        } else {
            return false;
        }
    }
}
コード例 #2
0
    /**
     * The admin menu for our AdSense system
     */
    function adsenseMenu()
    {
        $adsense = new AdsenseAdmin();
        if ($_GET['page'] == basename(__FILE__)) {
            if ('add' == $_REQUEST['action']) {
                $adsense->add($_REQUEST);
            } elseif ('toggle' == $_REQUEST['action']) {
                $adsense->toggle();
            } elseif ('pubid' == $_REQUEST['action']) {
                $adsense->pub_id($_REQUEST);
            } elseif ('delete' == $_REQUEST['action']) {
                $adsense->burninate($_REQUEST['id']);
            }
        }
        ?>
		<?php 
        if (isset($_REQUEST['add'])) {
            ?>
		<div id="message" class="updated fade"><p><strong><?php 
            echo __('Service added.');
            ?>
</strong></p></div>
		<?php 
        }
        ?>
			<div class="wrap">
			
				<div id="admin-options">
					<h2><?php 
        _e('AdSense Settings');
        ?>
</h2>
                    <p>Here you can add in your AdSense information and ad slot info so it can be displayed
                    on your blog. Need more help? <a href="#explain" title="Click for more info" id="explaintext">It's only a click away</a>.</p>
					<div id="explain">
                        <h3>For those that need help, here's a rundown:</h3>
                            <ol>
                                <li>Create an ad slot after logging into Google AdSense.</li>
                                <li>On this page, enter your pub-id and add enter ad details.</li>
                                <li>Enjoy. :-)</li>
                            </ol>
					</div>
					<form method="post" action="<?php 
        echo $_SERVER['PHP_SELF'];
        ?>
?page=adsenseads.php&toggle=true" class="form-table">
					<h2>Toggle AdSense Ads</h2>
					<p>One click button to disable the showing of AdSense ads.</p>
					<?php 
        if (wp_get_option('enable_adsense')) {
            if (wp_get_option('enable_adsense') == "true") {
                $val = "off";
            } else {
                $val = "on";
            }
        } else {
            $val = "on";
        }
        ?>
					<p class="submit">
					<input type="submit" name="toggle" value="Turn <?php 
        echo $val;
        ?>
 AdSense Ads" />
					<input type="hidden" name="action" value="toggle" />
					</p>
					</form>
					<p>To find an ad's ID number, first log in to Google AdSense. Next, click 'AdSense Setup' and then 'Manage Ads'.
					In the 'Name (#ID)' column find the ad you've created. The ad's ID will be underneath the ad's name in gray font.</p>
					<?php 
        if ($adsense->check() != 'false' && $adsense->count() != '') {
            ?>
					<table class="form-table" style="margin-bottom:30px;">
						<tr>
							<th>Ad ID</th>
							<th style="text-align:center;">Placement</th>
							<th style="text-align:center;" colspan="1">Actions</th>
						</tr>
					<?php 
            foreach ($adsense->collect() as $adslot) {
                ?>
		
						<tr>
							<td><?php 
                echo $adslot->ad_id;
                ?>
</td>
						   	<td style="text-align:center;">
        					   	<?php 
                if ($adslot->placement == 'blog_header') {
                    echo "Blog Header (728x90)";
                } elseif ($adslot->placement == 'blog_post_side') {
                    echo "Right of Blog Post (120x240)";
                } elseif ($adslot->placement == 'blog_post_bottom') {
                    echo "Underneath Home Post (300x250)";
                } elseif ($adslot->placement == 'blog_sidebar') {
                    echo "Bottom-left of Sidebar (120x600)";
                } else {
                    echo $adslot - placement;
                }
                ?>
						   	</td>
							<td style="text-align:center;">
							<form method="post" action="<?php 
                echo $_SERVER['PHP_SELF'];
                ?>
?page=adsenseads.php&amp;delete=true&amp;id=<?php 
                echo $adslot->id;
                ?>
">
								<input type="submit" name="action" value="Delete" />
								<input type="hidden" name="action" value="delete" />
							</form>
							</td>
						</tr>
					<?php 
            }
            ?>
					</table>
					<?php 
        } else {
            ?>
						<p>You haven't added any ad slots, add them here.</p>
					<?php 
        }
        ?>
					    <form method="post" action="<?php 
        echo $_SERVER['PHP_SELF'];
        ?>
?page=adsenseads.php&amp;pubid=true" class="form-table">
					        <h2>Google AdSense Publisher ID</h2>
					        <p>Please enter your AdSense Publisher ID here.</p>
					        <p style="font-style:italic;">The Publisher ID currently in use is:<br />
					        <?php 
        if (wp_get_option('adsense_pubid') != false && wp_option_isempty('adsense_pubid') == false) {
            echo wp_get_option('adsense_pubid');
        } else {
            echo "N/A";
        }
        ?>
					        </p>
					        <?php 
        if (wp_get_option('adsense_pubid')) {
            $pub_id = wp_get_option('adsense_pubid');
        } else {
            $pub_id = "Pub-ID";
        }
        ?>
					        <p><input type="text" name="pubid" id="pubid" onfocus="if(this.value=='<?php 
        echo $pub_id;
        ?>
')value=''" value="<?php 
        echo $pub_id;
        ?>
" /></p>
					        <p class="submit">
					            <input name="save" type="submit" value="Save Pub-ID" />
					            <input type="hidden" name="action" value="pubid" />
					        </p>
					    </form>
					    
						<form method="post" action="<?php 
        echo $_SERVER['PHP_SELF'];
        ?>
?page=adsenseads.php&amp;add=true" class="form-table">
							<h2>Add an Ad Slot</h2>
							<p>Please leave off the pound sign (#) when entering the Ad ID. Also remember, only one ad per placement. ;-)</p>
							<p><input type="text" name="ad_id" id="ad_id" onfocus="if(this.value=='Ad ID')value=''" value="Ad ID" /></p>
							<p><select name="placement" id="title">
                            <option value="blog_header">Blog header (728x90)</option>
                            <option value="blog_post_side">Right of Blog Post (120x240)</option>
                            <option value="blog_post_bottom">Underneath Home Post (300x250)</option>
                            <option value="blog_sidebar">Bottom-left of Sidebar (120x600)</option>
                            </select></p>
                            <p class="submit">
                                <input name="save" type="submit" value="Add Ad Slot" /> 
                                <input type="hidden" name="action" value="add" />
							</p>
						</form>
				</div>
                <?php 
        include_once 'advert.php';
    }