Пример #1
0
    /**
     * Display function for the Options panel
     */
    function display_options_builder()
    {
        ?>
		<form action="<?php 
        pf_admin_url();
        ?>
" method="post">
			<div class="wrap">
				<?php 
        echo 'Options';
        ?>
				
					<h3><?php 
        _e('Modules', 'pf');
        ?>
</h3>

					<p class="description"><?php 
        _e('<strong>PressForward Modules</strong> are addons to alter or improve the functionality of the plugin.', 'pf');
        ?>
</p>
				<?php 
        do_action('pf_admin_op_page');
        wp_nonce_field('pf_settings');
        ?>
					<br />
					
					<p><?php 
        $default_pf_link_value = get_option('pf_link_to_source', 0);
        echo '<input id="pf_link_to_source" name="pf_link_to_source" type="number" class="pf_link_to_source_class" value="' . $default_pf_link_value . '" />';
        echo '<label class="description" for="pf_link_to_source"> ' . __('Seconds to redirect user to source. (0 means no redirect)', 'pf') . ' </label>';
        ?>
</p>

					<p><?php 
        $default_pf_present_author_value = get_option('pf_present_author_as_primary', 'yes');
        ?>
						<select id="pf_present_author_as_primary" name="pf_present_author_as_primary">
							<option value="yes" <?php 
        if ($default_pf_present_author_value == 'yes') {
            echo 'selected="selected"';
        }
        ?>
>Yes</option>
							<option value="no" <?php 
        if ($default_pf_present_author_value == 'no') {
            echo 'selected="selected"';
        }
        ?>
>No</option>
						</select>					
					<?php 
        echo '<label class="description" for="pf_present_author_as_primary"> ' . __('Show item author as source.', 'pf') . ' </label>';
        ?>
</p>
					
					<input type="submit" name="submit" class="button-primary" value="<?php 
        _e("Save Changes", 'pf');
        ?>
" />
					<br />					
					
					<h3><?php 
        _e('User Control', 'pf');
        ?>
</h3>

				<?php 
        $arrayedAdminRights = array('pf_menu_group_access' => array('default' => 'contributor', 'title' => __('PressForward Menu Group', 'pf')), 'pf_menu_all_content_access' => array('default' => 'contributor', 'title' => __('All Content Menu', 'pf')), 'pf_menu_under_review_access' => array('default' => 'contributor', 'title' => __('Under Review Menu', 'pf')), 'pf_menu_preferences_access' => array('default' => 'administrator', 'title' => __('Preferences Menu', 'pf')), 'pf_menu_feeder_access' => array('default' => 'editor', 'title' => __('Feeder Menu', 'pf')), 'pf_menu_add_nomination_access' => array('default' => 'contributor', 'title' => __('Add Nomination Menu', 'pf')));
        $arrayedAdminRights = apply_filters('pf_setup_admin_rights', $arrayedAdminRights);
        foreach ($arrayedAdminRights as $right => $parts) {
            ?>
					<table class="form-table">
						<tr>
							<th scope="row">
								<label for="<?php 
            echo $right;
            ?>
-enable"><?php 
            echo $parts['title'];
            ?>
</label>
							</th>

							<td>
								<select id="<?php 
            echo $right;
            ?>
" name="<?php 
            echo $right;
            ?>
">
									<?php 
            $this->pf_get_user_role_select($right, pf_get_defining_capability_by_role($parts['default']));
            ?>
								</select>
							</td>
						</tr>
					</table>			
			
				<br />		
			
			<?php 
        }
        ?>
<input type="submit" name="submit" class="button-primary" value="<?php 
        _e("Save Changes", 'pf');
        ?>
" /><?php 
        do_action('pf_admin_user_settings');
        ?>
						
			</div>
		</form>
		<?php 
    }
-enable"><?php 
    echo $parts['title'];
    ?>
</label>
						</th>

						<td>
							<select id="<?php 
    echo $right;
    ?>
" name="<?php 
    echo $right;
    ?>
">
								<?php 
    pressforward()->admin->pf_get_user_role_select($right, pf_get_defining_capability_by_role($parts['default']));
    ?>
							</select>
						</td>
					</tr>
				</table>
			<p>
				<?php 
    if (!empty($parts['details'])) {
        echo $parts['details'];
    }
    ?>
			</p>
			<br />
			<hr />
Пример #3
0
 /**
  * Register the admin menu items
  *
  * The parent class will take care of registering them
  */
 function setup_admin_menus($admin_menus)
 {
     $admin_menus = array();
     $admin_menus[] = array('page_title' => __('View Log', 'pf'), 'menu_title' => __('View Log', 'pf'), 'cap' => get_option('pf_menu_log_access', pf_get_defining_capability_by_role('administrator')), 'slug' => 'pf-debugger', 'callback' => array($this, 'admin_menu_callback'));
     parent::setup_admin_menus($admin_menus);
 }
Пример #4
0
 function pf_options_admin_page_save()
 {
     global $pagenow;
     if ('admin.php' != $pagenow) {
         return;
     }
     if (empty($_POST['submit'])) {
         return;
     }
     check_admin_referer('pf_settings');
     if (current_user_can(get_option('pf_menu_all_content_access', pf_get_defining_capability_by_role('contributor')))) {
         $user_ID = get_current_user_id();
         if (isset($_POST['pf_user_scroll_switch'])) {
             $pf_user_scroll_switch = $_POST['pf_user_scroll_switch'];
             //var_dump($pf_user_scroll_switch); die();
             update_user_option($user_ID, 'pf_user_scroll_switch', $pf_user_scroll_switch);
         } else {
             update_user_option($user_ID, 'pf_user_scroll_switch', 'false');
         }
         if (isset($_POST['pf_user_menu_set'])) {
             $pf_user_menu_set = $_POST['pf_user_menu_set'];
             //var_dump($pf_user_scroll_switch); die();
             update_user_option($user_ID, 'pf_user_menu_set', $pf_user_menu_set);
         } else {
             update_user_option($user_ID, 'pf_user_menu_set', 'false');
         }
         if (isset($_POST['pf_pagefull'])) {
             $pf_pagefull = $_POST['pf_pagefull'];
             //var_dump($pf_user_scroll_switch); die();
             update_user_option($user_ID, 'pf_pagefull', $pf_pagefull);
         } else {
             update_user_option($user_ID, 'pf_pagefull', 'false');
         }
     }
     $verifyPages = array();
     $pf_admin_pages = apply_filters('pf_admin_pages', $verifyPages);
     if (!in_array($_GET['page'], $pf_admin_pages)) {
         return;
     }
     if (current_user_can(get_option('pf_menu_preferences_access', pf_get_defining_capability_by_role('administrator')))) {
         $arrayedAdminRights = array('pf_menu_group_access' => array('default' => 'contributor', 'title' => __('PressForward Menu Group', 'pf')), 'pf_menu_all_content_access' => array('default' => 'contributor', 'title' => __('All Content Menu', 'pf')), 'pf_menu_under_review_access' => array('default' => 'contributor', 'title' => __('Nominated Menu', 'pf')), 'pf_menu_preferences_access' => array('default' => 'administrator', 'title' => __('Preferences Menu', 'pf')), 'pf_menu_feeder_access' => array('default' => 'editor', 'title' => __('Add Feeds', 'pf')), 'pf_menu_add_nomination_access' => array('default' => 'contributor', 'title' => __('Add Nomination Menu', 'pf')));
         $arrayedAdminRights = apply_filters('pf_setup_admin_rights', $arrayedAdminRights);
         foreach ($arrayedAdminRights as $right => $parts) {
             if (isset($_POST[$right])) {
                 $enabled = $_POST[$right];
                 update_option($right, $enabled);
             }
         }
         if (isset($_POST['pf_link_to_source'])) {
             $pf_links_opt_check = $_POST['pf_link_to_source'];
             //print_r($pf_links_opt_check); die();
             update_option('pf_link_to_source', $pf_links_opt_check);
         } else {
             update_option('pf_link_to_source', 0);
         }
         if (isset($_POST['pf_retain_time'])) {
             $pf_links_opt_check = $_POST['pf_retain_time'];
             //print_r($pf_links_opt_check); die();
             update_option('pf_retain_time', $pf_links_opt_check);
         } else {
             update_option('pf_retain_time', 2);
         }
         if (isset($_POST['pf_errors_until_alert'])) {
             $pf_errors_until_alert = $_POST['pf_errors_until_alert'];
             //print_r($pf_links_opt_check); die();
             update_option('pf_errors_until_alert', $pf_errors_until_alert);
         } else {
             update_option('pf_errors_until_alert', 3);
         }
         if (isset($_POST['pf_present_author_as_primary'])) {
             $pf_author_opt_check = $_POST['pf_present_author_as_primary'];
             //print_r($pf_links_opt_check); die();
             update_option('pf_present_author_as_primary', $pf_author_opt_check);
         } else {
             update_option('pf_present_author_as_primary', 'no');
         }
         if (class_exists('The_Alert_Box')) {
             #var_dump($_POST);
             if (empty($_POST[the_alert_box()->option_name()])) {
                 #var_dump('<pre>'); var_dump($_POST); var_dump('</pre>');
                 update_option(the_alert_box()->option_name(), 'false');
             } else {
                 update_option(the_alert_box()->option_name(), $_POST[the_alert_box()->option_name()]);
             }
         }
         if (isset($_POST['pf_use_advanced_user_roles'])) {
             $pf_author_opt_check = $_POST['pf_use_advanced_user_roles'];
             //print_r($pf_links_opt_check); die();
             update_option('pf_use_advanced_user_roles', $pf_author_opt_check);
         } else {
             update_option('pf_use_advanced_user_roles', 'no');
         }
     }
     do_action('pf_admin_op_page_save');
 }
Пример #5
0
 /**
  * Handles AJAX insert comment
  */
 function ajax_insert_comment()
 {
     global $current_user, $user_ID, $wpdb;
     // Verify nonce
     if (!wp_verify_nonce($_POST['_nonce'], 'comment')) {
         die(__("Nonce check failed. Please ensure you're supposed to be adding editorial comments.", 'pf'));
     }
     // Get user info
     get_currentuserinfo();
     $comments_allowed = get_option('pf_feature_comments_access', pf_get_defining_capability_by_role('editor'));
     // Set up comment data
     $post_id = absint($_POST['post_id']);
     $parent = absint($_POST['parent']);
     // Only allow the comment if user can edit post
     // @TODO: allow contributers to add comments as well (?)
     if (!current_user_can($comments_allowed, $post_id)) {
         die(__('Sorry, you don\'t have the privileges to add editorial comments. Please talk to your Administrator.', 'pf'));
     }
     // Verify that comment was actually entered
     $comment_content = trim($_POST['content']);
     if (!$comment_content) {
         die(__("Please enter a comment.", 'pf'));
     }
     // Check that we have a post_id and user logged in
     if ($post_id && $current_user) {
         // set current time
         $time = current_time('mysql', $gmt = 0);
         // Set comment data
         $data = array('comment_post_ID' => (int) $post_id, 'comment_author' => esc_sql($current_user->display_name), 'comment_author_email' => esc_sql($current_user->user_email), 'comment_author_url' => esc_sql($current_user->user_url), 'comment_content' => wp_kses($comment_content, array('a' => array('href' => array(), 'title' => array()), 'b' => array(), 'i' => array(), 'strong' => array(), 'em' => array(), 'u' => array(), 'del' => array(), 'blockquote' => array(), 'sub' => array(), 'sup' => array())), 'comment_type' => self::comment_type, 'comment_parent' => (int) $parent, 'user_id' => (int) $user_ID, 'comment_author_IP' => esc_sql($_SERVER['REMOTE_ADDR']), 'comment_agent' => esc_sql($_SERVER['HTTP_USER_AGENT']), 'comment_date' => $time, 'comment_date_gmt' => $time, 'comment_approved' => self::comment_type);
         apply_filters('ef_pre_insert_editorial_comment', $data);
         // Insert Comment
         $comment_id = wp_insert_comment($data);
         $comment = get_comment($comment_id);
         // Register actions -- will be used to set up notifications and other modules can hook into this
         if ($comment_id) {
             do_action('ef_post_insert_editorial_comment', $comment);
         }
         // Prepare response
         $response = new WP_Ajax_Response();
         ob_start();
         $this->the_comment($comment, '', '');
         $comment_list_item = ob_get_contents();
         ob_end_clean();
         $comment_count = self::get_editorial_comment_count($post_id);
         $response->add(array('what' => 'comment', 'id' => $comment_id, 'data' => $comment_list_item, 'action' => $parent ? 'reply' : 'new', 'supplemental' => array('post_comment_count' => $comment_count, 'post_id' => $post_id)));
         $response->send();
     } else {
         die(__('There was a problem of some sort. Try again or contact your administrator.', 'edit-flow'));
     }
 }
 public function permitted_tabs()
 {
     $permitted_tabs = array('user' => array('title' => __('User Options', 'pf'), 'cap' => get_option('pf_menu_all_content_access', pf_get_defining_capability_by_role('contributor'))), 'site' => array('title' => __('Site Options', 'pf'), 'cap' => get_option('pf_menu_preferences_access', pf_get_defining_capability_by_role('administrator'))), 'user-control' => array('title' => __('User Control', 'pf'), 'cap' => get_option('pf_menu_preferences_access', pf_get_defining_capability_by_role('administrator'))), 'modules' => array('title' => __('Module Control', 'pf'), 'cap' => get_option('pf_menu_preferences_access', pf_get_defining_capability_by_role('administrator'))));
     $permitted_tabs = apply_filters('pf_settings_tabs', $permitted_tabs);
     return $permitted_tabs;
 }
Пример #7
0
						</select>
				<?php 
}
echo '</div>';
?>
                <div class="alert-box">
                    <h3><span>Feed Problems</span></h3>
                    <div class="inside">
                    <?php 
pressforward()->admin->pf_alert_displayer();
?>
                    </div>
                </div>

			<?php 
if ($slug == 'toplevel_page_pf-menu' && $version >= 0 && current_user_can(pf_get_defining_capability_by_role('administrator'))) {
    ?>

						<button type="submit" class="delete btn btn-danger pull-right" id="deletefeedarchive" value="<?php 
    _e('Delete all items', 'pf');
    ?>
" ><?php 
    _e('Delete all items', 'pf');
    ?>
</button>
				<?php 
}
do_action('pf_side_menu_widgets', $slug);
?>

		</div>