コード例 #1
0
function caa_save_new_custom_author()
{
    global $wpdb;
    //Save New Author
    $username = $_POST["username"];
    if ($username == "") {
        return caa_return_message("Error! Username is required!", "error");
    }
    $email = $_POST["email"];
    $first_name = $_POST["first_name"];
    $last_name = $_POST["last_name"];
    $url = $_POST["url"];
    $description = $_POST["description"];
    $twitter = $_POST["twitter"];
    $facebook = $_POST["facebook"];
    $google_plus = $_POST["google_plus"];
    $linkedin = $_POST["linkedin"];
    $flickr = $_POST["flickr"];
    $youtube = $_POST["youtube"];
    $vimeo = $_POST["vimeo"];
    $skype = $_POST["skype"];
    $xing = $_POST["xing"];
    $custom_link_1 = $_POST["custom_link_1"];
    $custom_icon_1 = $_POST["custom_icon_1"];
    $custom_link_2 = $_POST["custom_link_2"];
    $custom_icon_2 = $_POST["custom_icon_2"];
    $custom_link_3 = $_POST["custom_link_3"];
    $custom_icon_3 = $_POST["custom_icon_3"];
    $use_custom_image = null;
    if (isset($_POST['use_custom_image'])) {
        $use_custom_image = $_POST["use_custom_image"];
    }
    $custom_image_url = $_POST["custom_image_url"];
    $display_html_block = null;
    if (isset($_POST['display_html_block'])) {
        $display_html_block = $_POST["display_html_block"];
    }
    $html_block = $_POST["html_block"];
    $custom_author_table = new CAA_Profile_DB($wpdb);
    if ($custom_author_table->get_row_by_username($username) != null) {
        //username already exist
        return caa_return_message("Error! Username <strong>" . $username . "</stong> already exists!", "error");
    }
    $profile_id = $custom_author_table->create_new_row($username, $first_name, $last_name, $email, $url, $description, $twitter, $facebook, $google_plus, $linkedin, $flickr, $youtube, $vimeo, $skype, $xing, $custom_link_1, $custom_icon_1, $custom_link_2, $custom_icon_2, $custom_link_3, $custom_icon_3, $use_custom_image, $custom_image_url, $display_html_block, $html_block);
    if ($profile_id) {
        $message = "Custom Author Successfully Added " . "<a href='admin.php?page=" . CAA_Config::display_all_custom_authors_page . "'>Back to all custom authors</a>";
        return caa_return_message($message, "updated");
    } else {
        return caa_return_message("Error Adding Custom Author!", "error");
    }
}
コード例 #2
0
function caa_display_all_custom_authors($display_text)
{
    global $wpdb;
    $custom_authors_database = new CAA_Profile_DB($wpdb);
    ?>
	<div class="wrap">
		<div id="icon-users" class="icon32"><br /></div>
		<h2>Custom Authors	<a href="admin.php?page=<?php 
    echo CAA_Config::add_new_custom_author_page;
    ?>
" class="add-new-h2">Add New</a></h2>
		<p>&nbsp;</p>
	<?php 
    echo $display_text;
    $entryResults = $custom_authors_database->get_all_rows();
    if ($entryResults) {
        caa_display_entries_header_and_footer();
        foreach ($entryResults as $singleEntryResult) {
            $profile_id = $singleEntryResult->{CAA_Profile_DB::profile_id};
            $username = $singleEntryResult->{CAA_Profile_DB::username};
            $first_name = $singleEntryResult->{CAA_Profile_DB::first_name};
            $last_name = $singleEntryResult->{CAA_Profile_DB::last_name};
            $email = $singleEntryResult->{CAA_Profile_DB::email};
            $image_size = 40;
            $author_image = get_avatar($email, $image_size);
            echo '<tr>';
            echo '<td>' . $author_image . $username;
            caa_include_row_options($profile_id, $username);
            echo '</td>';
            echo '<td>' . $first_name . '</td>';
            echo '<td>' . $last_name . '</td>';
            echo '<td>' . $email . '</td>';
            echo '</tr>';
        }
        caa_display_entries_close_table();
    } else {
        echo "<p>There are currently no custom authors. Why not <a href=\"admin.php?page=" . CAA_Config::add_new_custom_author_page . "\">add one</a>?</p>";
    }
    caa_update_global_settings();
    echo caa_display_global_settings();
    echo caa_display_documentation_link();
    echo caa_display_donation_link();
    echo caa_display_promo_for_other_plugins();
    ?>
	</div>
	<?php 
}
コード例 #3
0
function caa_edit_custom_author($display_text, $profile_id)
{
    global $wpdb, $caa_plugin_dir_path;
    $custom_author_table = new CAA_Profile_DB($wpdb);
    $result = $custom_author_table->get_row_by_id($profile_id);
    ?>
	<div class="wrap">
	<div style="display:none" id="plugin_url"><?php 
    echo $caa_plugin_dir_path;
    ?>
</div>	<!-- Store plugin url path here here for use by javascript -->
	<div id="icon-users" class="icon32"><br /></div>
	<h2>Edit Custom Author <a href="admin.php?page=<?php 
    echo CAA_Config::display_all_custom_authors_page;
    ?>
" class='button'><?php 
    _e('Back');
    ?>
 </a></h2>
	<?php 
    echo $display_text;
    $author = caa_get_author_details_from_database($result->username, true);
    $author_display_box = caa_get_author_bio_html($author);
    echo $author_display_box;
    ?>
	
	<form action="" method="post" id="createuser">
	<input type="hidden" name="profile_id" value="<?php 
    echo $profile_id;
    ?>
"/>
		<table class="form-table">
			<tr class="form-field form-required">
				<th scope="row"><label for="username">Username </label></th>
				<td><?php 
    echo $result->username;
    ?>
</td>
			</tr>
			<tr class="form-field form-required">
				<th scope="row"><label for="short-code">Short-code </label></th>
				<td><strong>[custom_author=<?php 
    echo $result->username;
    ?>
]</strong></td>
			</tr>			
			<tr class="form-field">
				<th scope="row"><label for="email">E-mail</label></th>
				<td><input name="email" type="text" id="email" value="<?php 
    echo $result->email;
    ?>
" /></td>
			</tr>
			<tr class="form-field">
				<th scope="row"><label for="first_name">First Name</label></th>
				<td><input name="first_name" type="text" id="first_name" value="<?php 
    echo $result->first_name;
    ?>
" /></td>
			</tr>
			<tr class="form-field">
				<th scope="row"><label for="last_name">Last Name</label></th>
				<td><input name="last_name" type="text" id="last_name" value="<?php 
    echo $result->last_name;
    ?>
" /></td>
			</tr>
			<tr class="form-field">
				<th scope="row"><label for="url">Website</label></th>
				<td><input name="url" type="text" id="url" value="<?php 
    echo $result->url;
    ?>
" /></td>
			</tr>
			<tr>
				<th scope="row"><label for="description">Description</label></th>
				<td><textarea name="description" id="description" rows="5" cols="50" ><?php 
    echo $result->description;
    ?>
</textarea></td>
			</tr>
			<tr>
				<th scope="row"><label for="twitter">Twitter</label></th>
				<td><?php 
    echo CAA_Config::twitter_url_prefix;
    ?>
<input name="twitter" type="text" id="twitter" value="<?php 
    echo $result->twitter;
    ?>
" /></td>
			</tr>
			<tr>
				<th scope="row"><label for="facebook">Facebook</label></th>
				<td><?php 
    echo CAA_Config::facebook_url_prefix;
    ?>
<input name="facebook" type="text" id="facebook" value="<?php 
    echo $result->facebook;
    ?>
" /></td>
			</tr>
			<tr>
				<th scope="row"><label for="google_plus">Google+</label></th>
				<td><?php 
    echo CAA_Config::google_plus_url_prefix;
    ?>
<input name="google_plus" type="text" id="google_plus" value="<?php 
    echo $result->google_plus;
    ?>
" /></td>
			</tr>
			<tr>
				<th scope="row"><label for="linkedin">LinkedIn</label></th>
				<td><?php 
    echo CAA_Config::linkedin_url_prefix;
    ?>
<input name="linkedin" type="text" id="linkedin" value="<?php 
    echo $result->linkedin;
    ?>
" /></td>
			</tr>
			<tr>
				<th scope="row"><label for="flickr">Flickr</label></th>
				<td><?php 
    echo CAA_Config::flickr_url_prefix;
    ?>
<input name="flickr" type="text" id="flickr" value="<?php 
    echo $result->flickr;
    ?>
" /></td>
			</tr>
			<tr>
				<th scope="row"><label for="youtube">YouTube</label></th>
				<td><?php 
    echo CAA_Config::youtube_url_prefix;
    ?>
<input name="youtube" type="text" id="youtube" value="<?php 
    echo $result->youtube;
    ?>
" /></td>
			</tr>
			<tr>
				<th scope="row"><label for="vimeo">Vimeo</label></th>
				<td><?php 
    echo CAA_Config::vimeo_url_prefix;
    ?>
<input name="vimeo" type="text" id="vimeo" value="<?php 
    echo $result->vimeo;
    ?>
" /></td>
			</tr>
			<tr>
				<th scope="row"><label for="skype">Skype</label></th>
				<td><?php 
    echo CAA_Config::skype_url_prefix;
    ?>
<input name="skype" type="text" id="skype" value="<?php 
    echo $result->skype;
    ?>
" />?userinfo</td>
			</tr>
			<tr>
				<th scope="row"><label for="xing">Xing</label></th>
				<td><?php 
    echo CAA_Config::xing_url_prefix;
    ?>
<input name="xing" type="text" id="xing" value="<?php 
    echo $result->xing;
    ?>
" /></td>
			</tr>
			<tr>
				<th scope="row"><label for="custom_1">Custom 1</label></th>
				<td>Icon url:<input name="custom_icon_1" type="text" id="custom_icon_1" value="<?php 
    echo $result->custom_icon_1;
    ?>
" /> Link url:<input name="custom_link_1" type="text" id="custom_link_1" value="<?php 
    echo $result->custom_link_1;
    ?>
" /></td>
			</tr>
			<tr>
				<th scope="row"><label for="custom_2">Custom 2</label></th>
				<td>Icon url:<input name="custom_icon_2" type="text" id="custom_icon_2" value="<?php 
    echo $result->custom_icon_2;
    ?>
" /> Link url:<input name="custom_link_2" type="text" id="custom_link_2" value="<?php 
    echo $result->custom_link_2;
    ?>
" /></td>
			</tr>
			<tr>
				<th scope="row"><label for="custom_3">Custom 3</label></th>
				<td>Icon url:<input name="custom_icon_3" type="text" id="custom_icon_3" value="<?php 
    echo $result->custom_icon_3;
    ?>
" /> Link url:<input name="custom_link_3" type="text" id="custom_link_3" value="<?php 
    echo $result->custom_link_3;
    ?>
" /></td>
			</tr>            
			<tr>
				<th scope="row"><label for="use_custom_image">Use Custom Author Image <span class="description"><br/>(uses <a href="http://gravatar.com" target="_new">Gravatar</a> if unchecked)</span></label></th>
				<td><input name="use_custom_image" type="checkbox" id="use_custom_image"
				<?php 
    if ($result->use_custom_image) {
        echo "checked";
    }
    ?>
 
				/></td>
			</tr>
			<tr class="form-field">
				<th scope="row"><label for="custom_image_url">Custom Author Image location <span class="description"><br/>(will be re-sized to 75x75 pixels)</span></label></th>
				<td><input name="custom_image_url" type="text" id="custom_image_url" value="<?php 
    echo $result->custom_image_url;
    ?>
" /></td>
			</tr>		
			<tr>
				<th scope="row"><label for="display_html_block">Use Custom HTML</label></th>
				<td><input name="display_html_block" type="checkbox" id="display_html_block"
				<?php 
    if ($result->display_html_block) {
        echo "checked";
    }
    ?>
 
				/></td>
			</tr>
			<tr>
				<th scope="row"><label for="html_block">Custom HTML <span class="description"><br/>(use <img src="<?php 
    echo $caa_plugin_dir_path;
    ?>
/utils/HtmlBox/images/silk/code.png"/> to display HTML code)</span></label></th>
				<td><textarea name="html_block" id="html_block" rows="5" cols="50" ><?php 
    echo $result->html_block;
    ?>
</textarea></td>
			</tr>		
		</table>
	
	<p class="submit">
	<input type="submit" name="createuser" id="createusersub" class="button-primary" value="Save Changes"  />
	<a href="admin.php?page=<?php 
    echo CAA_Config::display_all_custom_authors_page;
    ?>
&action=delete&profile_id=<?php 
    echo $profile_id;
    ?>
" 
		onclick="return confirm('Confirm Deletion of <?php 
    echo $result->username;
    ?>
?')">Delete</a>
	</p>
	</form>	
	</div>
	<?php 
}
コード例 #4
0
function caa_get_author_details_from_database($username, $convert_line_feeds_to_br = false)
{
    global $wpdb;
    $database_author_details = null;
    $author_profile_db = new CAA_Profile_DB($wpdb);
    $result = $author_profile_db->get_row_by_username($username);
    if ($result) {
        $author_description = $result->description;
        if ($convert_line_feeds_to_br) {
            $author_description = caa_replace_linefeeds_to_br($author_description);
        }
        $database_author_details = array(CAA_Author::first_name => $result->first_name, CAA_Author::last_name => $result->last_name, CAA_Author::user_email => $result->email, CAA_Author::user_url => $result->url, CAA_Author::description => $author_description, CAA_Author::twitter => $result->twitter, CAA_Author::facebook => $result->facebook, CAA_Author::google_plus => $result->google_plus, CAA_Author::linkedin => $result->linkedin, CAA_Author::flickr => $result->flickr, CAA_Author::youtube => $result->youtube, CAA_Author::vimeo => $result->vimeo, CAA_Author::skype => $result->skype, CAA_Author::xing => $result->xing, CAA_Author::custom_icon_1 => $result->custom_icon_1, CAA_Author::custom_link_1 => $result->custom_link_1, CAA_Author::custom_icon_2 => $result->custom_icon_2, CAA_Author::custom_link_2 => $result->custom_link_2, CAA_Author::custom_icon_3 => $result->custom_icon_3, CAA_Author::custom_link_3 => $result->custom_link_3, CAA_Profile_DB::use_custom_image => $result->use_custom_image, CAA_Profile_DB::custom_image_url => $result->custom_image_url, CAA_Profile_DB::display_html_block => $result->display_html_block, CAA_Profile_DB::html_block => $result->html_block);
    }
    return $database_author_details;
}
コード例 #5
0
ファイル: installer.php プロジェクト: patlegris/On-off-Studio
<?php

/**
 * Activation of plugin
 *
 * Things that run once when the plugin is activated
 *
 * Reference Documentation
 * http://codex.wordpress.org/Function_Reference/wpdb_Class
 * http://codex.wordpress.org/Creating_Tables_with_Plugins
 */
include_once dirname(__FILE__) . '/includes/includes-master-list.php';
global $wpdb;
//create the custom author database
$custom_author_database_table = new CAA_Profile_DB($wpdb);
$custom_author_database_table->create_table();
$custom_author_database_table->upgrade_table();