Beispiel #1
0
<input id="cwp_top_currenturl" type="hidden" value="<?php 
echo CURRENTURL;
?>
" data-cnetwork="<?php 
echo CWP_TOP_Core::getCurrentNetwork();
?>
">
<?php 
$networks = $this->getAllNetworks(true);
foreach ($networks as $an => $pro) {
    ?>

		<fieldset class="option <?php 
    if ($pro !== CWP_TOP_PRO) {
        ?>
 pro-ver <?php 
    }
    ?>
 ">
				<div class="left">
					<label for="<?php 
    echo $an;
    ?>
-login"> <?php 
    _e(ucwords($an) . " Login", 'tweet-old-post');
    ?>
 </label>
					<span class='description'> <?php 
    _e("Login using your " . ucwords($an) . " account.", 'tweet-old-post');
    ?>
 </span>
Beispiel #2
0
 public function setAlloAuthSettings()
 {
     global $cwp_top_settings;
     $this->consumer = $cwp_top_settings['oAuth_settings']['consumer_key'];
     $this->consumerSecret = $cwp_top_settings['oAuth_settings']['consumer_secret'];
     $this->oAuthCallback = CURRENTURL;
     $this->cwp_top_access_token = get_option('cwp_top_access_token');
     $this->cwp_top_oauth_token = get_option('cwp_top_oauth_token');
     $this->cwp_top_oauth_token_secret = get_option('cwp_top_oauth_token_secret');
     $this->user_info = get_option('cwp_top_oauth_user_details');
     $this->users = apply_filters("rop_users_filter", get_option('cwp_top_logged_in_users'));
     $this->pluginStatus = get_option('cwp_topnew_active_status');
     $this->intervalSet = get_option('top_opt_interval');
     self::$date_format = 'M j, Y @ G:i';
     //update_option('cwp_top_logged_in_users', '');
 }
function rop_exclude_posts()
{
    if (current_user_can('manage_options')) {
        global $wpdb;
        $message_updated = __("Tweet Old Post Options Updated.", 'TweetOldPost');
        $records_per_page = 20;
        $twp_obj = new CWP_TOP_Core();
        $paged = isset($_POST['paged']) ? $_POST['paged'] : 1;
        $postTypes = $twp_obj->getTweetPostType();
        $postTypes = explode(',', $postTypes);
        $selected_post_type = isset($_POST['rop_select_post_type']) ? $_POST['rop_select_post_type'] : $postTypes[0];
        $selected_tax = isset($_POST['rop_select_category']) ? $_POST['rop_select_category'] : "none";
        $displayed_posts = array();
        $exclude_search = isset($_POST['s']) ? $_POST['s'] : "";
        $excluded_cats = get_option('top_opt_omit_cats');
        if (is_array($excluded_cats)) {
            $excluded_cats = implode(",", $excluded_cats);
        }
        if (empty($excluded_cats)) {
            $excluded_cats = '';
        }
        if (!is_string($excluded_cats)) {
            $excluded_cats = '';
        }
        $excluded_cats = trim($excluded_cats);
        $excluded_display_option = array("all" => "All", "excluded" => "Excluded", "unexcluded" => "Unexcluded");
        $excluded_display_selected = isset($_POST['rop_display_selection']) ? $_POST['rop_display_selection'] : key($excluded_display_option);
        $taxs = get_taxonomies(array('public' => true, 'hierarchical' => true), "object", "and");
        $available_taxonomy = array();
        foreach ($postTypes as $pt) {
            foreach ($taxs as $kt => $tx) {
                if (in_array($pt, $tx->object_type)) {
                    if (!isset($available_taxonomy[$kt])) {
                        $available_taxonomy[$kt] = array("label" => $tx->label);
                    }
                    if (!isset($available_taxonomy[$kt]['post_types'])) {
                        $available_taxonomy[$kt]['post_types'] = array();
                    }
                    $available_taxonomy[$kt]['post_types'] = array_merge($available_taxonomy[$kt]['post_types'], $tx->object_type);
                    if (!isset($available_taxonomy[$kt]['taxs'])) {
                        $available_taxonomy[$kt]['taxs'] = array();
                    }
                    $terms = get_terms($tx->name, array('hide_empty' => false, 'exclude' => $excluded_cats));
                    foreach ($terms as $t) {
                        $available_taxonomy[$kt]['taxs'][$t->term_id] = $t->name;
                    }
                }
            }
        }
        $excluded_ids = get_option('top_opt_excluded_post');
        $excluded_ids = array_filter(explode(',', $excluded_ids));
        if (isset($_POST['exclude'])) {
            if (!isset($_POST['rop_post_id'])) {
                $_POST['rop_post_id'] = array();
            }
            $show_items = explode(',', $_POST['rop_show_posts']);
            $dif = array_diff($show_items, $_POST['rop_post_id']);
            $com = array_intersect($dif, $excluded_ids);
            $excluded_ids = array_diff($excluded_ids, $com);
            $excluded_ids = array_merge($excluded_ids, $_POST['rop_post_id']);
            $excluded_ids = array_unique($excluded_ids);
            update_option('top_opt_excluded_post', implode(',', $excluded_ids));
        }
        if (isset($_POST['exclude']) || isset($_POST['search'])) {
            $paged = 1;
        }
        if (isset($_POST['exclude'])) {
            print '
			<div id="message" style="margin-top:30px" class="updated fade">
				<p>' . __('Posts excluded successfully.', 'TweetOldPost') . '</p>
			</div>';
        }
        require_once plugin_dir_path(__FILE__) . "view-exclude.php";
        $sql = "SELECT p.ID,p.post_title,p.post_date,u.user_nicename,p.guid,p.post_type FROM {$wpdb->posts} p join  {$wpdb->users} u on p.post_author=u.ID WHERE (post_type = '{$selected_post_type}')\r\n                  AND post_status = 'publish'";
        if ($selected_tax != 'none') {
            $sql = $sql . " and p.ID IN ( SELECT tr.object_id FROM " . $wpdb->prefix . "term_relationships AS tr INNER JOIN " . $wpdb->prefix . "term_taxonomy AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.term_id=" . $selected_tax . " ";
            if (!empty($excluded_cats)) {
                $sql .= " and tr.object_id NOT IN ( SELECT tr.object_id FROM " . $wpdb->prefix . "term_relationships AS tr INNER JOIN " . $wpdb->prefix . "term_taxonomy AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id AND tt.term_id  IN (" . $excluded_cats . ")) ) ";
            } else {
                $sql .= ")";
            }
        } else {
            if (!empty($excluded_cats)) {
                $sql = $sql . " and p.ID NOT IN ( SELECT tr.object_id FROM " . $wpdb->prefix . "term_relationships AS tr INNER JOIN " . $wpdb->prefix . "term_taxonomy AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id AND tt.term_id  IN (" . $excluded_cats . "))";
            }
        }
        if ($excluded_display_selected == "excluded") {
            $sql = $sql . " and p.ID IN (" . implode(",", $excluded_ids) . ")";
        }
        if ($excluded_display_selected == "unexcluded" && !empty($excluded_ids)) {
            $sql = $sql . " and p.ID NOT in (" . implode(",", $excluded_ids) . ")";
        }
        if (!empty($exclude_search)) {
            $sql = $sql . " and post_title like '%" . trim($exclude_search) . "%'";
        }
        $sql = $sql . " order by post_date desc";
        $posts = $wpdb->get_results($sql);
        $from = $paged * $records_per_page - $records_per_page;
        $to = min($paged * $records_per_page, count($posts));
        $post_count = count($posts);
        print '<form id="top_TweetOldPost" name="top_TweetOldPost" action="' . get_bloginfo('wpurl') . '/wp-admin/admin.php?page=ExcludePosts" method="post">';
        print '
			<script language="javascript">

            function ROPshowCorectTax(){
                var post_type = jQuery("#rop_select_post_type").val();
                jQuery("#rop_select_category optgroup").each(function(){
                var pt = jQuery(this).attr("data-post-type").split(",");
                var th = jQuery(this);
                if(jQuery.inArray(post_type,pt) > -1){
                    th.show();
                }else{
                    th.hide();
                }


            });

}
            jQuery(function() {
                jQuery("#rop_select_post_type").on("change",function(){
                    ROPshowCorectTax();

                });
                ROPshowCorectTax();
            });
            function checkedAll() {
                if(jQuery("rop-header-check").is("checked")){
                    jQuery(".rop_post_id").attr("checked","checked");

                }else{

                    jQuery(".rop_post_id").removeAttr("checked" );

                }
             }
			jQuery(document).ready(function(){
                    jQuery("#top_TweetOldPost").on("click",".page-numbers",function(){
                        var paged = jQuery(this).text();
                        jQuery("#post-search-page").val(paged);
                        jQuery("#top_TweetOldPost").submit();
                        return false;
                    })
			})

			</script>
		';
        print '<div class="tablenav"><div class="alignleft actions">';
        ?>
  <p class="rop-exclude-filter">
                <label>View: </label>
                <select name="rop_display_selection" id="selFilter" style="width:100px">
                    <?php 
        foreach ($excluded_display_option as $value => $name) {
            ?>
                        <option value="<?php 
            echo $value;
            ?>
" <?php 
            selected($value, $excluded_display_selected);
            ?>
 > <?php 
            echo $name;
            ?>
</option>
                    <?php 
        }
        ?>
                </select>
            </p>
            <p class="rop-exclude-filter">
                <label>Post type</label>
                <select name="rop_select_post_type" id="rop_select_post_type">
                    <?php 
        foreach ($postTypes as $pt) {
            ?>
                        <option value="<?php 
            echo $pt;
            ?>
" <?php 
            selected($pt, $selected_post_type);
            ?>
><?php 
            echo $pt;
            ?>
</option>
                     <?php 
        }
        ?>

                </select>
            </p>

            <p class="rop-exclude-filter">
                <label>Category</label>
                <select name="rop_select_category" id="rop_select_category">
                    <option value="none"> All </option>
                    <?php 
        foreach ($available_taxonomy as $at) {
            ?>
                        <optgroup label="<?php 
            echo $at['label'];
            ?>
" data-post-type="<?php 
            echo implode(',', $at['post_types']);
            ?>
">
                            <?php 
            foreach ($at['taxs'] as $id => $tax) {
                ?>
                                    <option value="<?php 
                echo $id;
                ?>
" <?php 
                selected($id, $selected_tax);
                ?>
><?php 
                echo $tax;
                ?>
</option>
                            <?php 
            }
            ?>
                        </optgroup>

                    <?php 
        }
        ?>

                </select>
            </p>
            <?php 
        print '<p class="search-box" style="margin:0px">
	<input type="text" id="post-search-input" name="s" value="' . $exclude_search . '" />
	<input type="hidden" id="post-search-page" name="paged" value="' . $paged . '" />
	<input type="submit" value="Search Posts" name="search" class="button" />
	<input type="submit" value="Exclude selected" name="exclude" class="button" />
</p>';
        print '</div>';
        $page_links = paginate_links(array('base' => add_query_arg('paged', '%#%'), 'format' => '', 'prev_text' => __('&laquo;'), 'next_text' => __('&raquo;'), 'total' => ceil(count($posts) / $records_per_page), 'current' => $paged));
        if ($page_links) {
            print '<div class="tablenav-pages">';
            $page_links_text = sprintf('<span class="displaying-num">' . __('Displaying %s&#8211;%s of %s') . '</span>%s', number_format_i18n(($paged - 1) * $records_per_page + 1), number_format_i18n(min($paged * $records_per_page, count($posts))), number_format_i18n(count($posts)), $page_links);
            echo $page_links_text;
            print '</div>';
        }
        print '</div>';
        //tablenav div
        if (count($posts) > 0) {
            print '	<div class="wrap">
				<table class="widefat fixed">
					<thead>
					<tr>
						<th class="manage-column column-cb check-column"><input name="headchkbx" id="rop-header-check" onchange="javascript:checkedAll();" type="checkbox" value="checkall"/></th>
						<th>No.</th>
						<th>Id</th>
						<th>Post Title</th>
						<th>Author</th>
						<th>Post Date</th>
					</tr>
					</thead>
					<tbody>
		';
            for ($i = $from; $i < $to; $i++) {
                $displayed_posts[] = $posts[$i]->ID;
                if (in_array($posts[$i]->ID, $excluded_ids)) {
                    $checked = "Checked";
                    $bgcolor = "#FFCC99";
                } else {
                    $checked = "";
                    $bgcolor = "#FFF";
                }
                $displayed_posts[] = $posts[$i]->ID;
                print '

				<tr style="background-color:' . $bgcolor . ';">
					<th class="check-column">
						<input type="checkbox" name="rop_post_id[]" class="rop_post_id" id="del' . $posts[$i]->ID . '"  value="' . $posts[$i]->ID . '" ' . $checked . '/>
					</th>
					<td>
						' . ($i + 1) . '
					</td>
					<td>
						' . $posts[$i]->ID . '
					</td>
					<td>
						<a href=' . get_permalink($posts[$i]->ID) . ' target="_blank">' . $posts[$i]->post_title . '</a>
					</td>
					<td>
                                            ' . $posts[$i]->user_nicename . '
                                        </td>
                                        <td>
                                            ' . $posts[$i]->post_date . '
                                        </td>
				</tr>

			';
            }
            print '
				</tbody>
				</table>
			</div>
		';
            ?>
            <input type="hidden" name="rop_show_posts" value="<?php 
            echo implode(',', $displayed_posts);
            ?>
"/>
        <?php 
            if ($page_links) {
                print '<div class="tablenav"> <div class="tablenav-pages">';
                $page_links_text = sprintf('<span class="displaying-num">' . __('Displaying %s&#8211;%s of %s') . '</span>%s', number_format_i18n(($paged - 1) * $records_per_page + 1), number_format_i18n(min($paged * $records_per_page, count($posts))), number_format_i18n(count($posts)), $page_links);
                echo $page_links_text;
                print '</div></div> ';
            }
        } else {
            print '<div class="wrap">
			<div id="message" style="margin-top:30px" class="updated fade">
				<p>' . __('No Posts found. Review your search or filter criteria/term.', 'TweetOldPost') . '</p>
			</div></div>';
        }
        print '</form></section>';
    } else {
        print '
                <div id="message" class="updated fade">
                    <p>' . __('You do not have enough permission to set the option. Please contact your admin.', 'TweetOldPost') . '</p>
                </div>';
    }
}
 </span>

							<?php 
        if ($field['type'] == 'categories-list') {
            ?>
								<button class='select-all'><?php 
            _e("Select All", 'tweet-old-post');
            ?>
</button>
							<?php 
        }
        ?>

						</div><!-- end .left -->
						<div class="right">
							<?php 
        CWP_TOP_Core::generateFieldType($field);
        ?>
						</div><!-- end .right -->
					</fieldset><!-- end .option -->
				<?php 
    }
    ?>
		</div>
		<?php 
    $first = false;
}
?>


</div>
 /**
  * Make an HTTP request
  *
  * @return API results
  */
 function http($url, $method, $postfields = NULL, $authorization_header = false)
 {
     $this->http_info = array();
     $ci = curl_init();
     $headers = array('Expect:');
     curl_setopt($ci, CURLOPT_USERAGENT, $this->useragent);
     curl_setopt($ci, CURLOPT_CONNECTTIMEOUT, $this->connecttimeout);
     curl_setopt($ci, CURLOPT_TIMEOUT, $this->timeout);
     curl_setopt($ci, CURLOPT_RETURNTRANSFER, TRUE);
     curl_setopt($ci, CURLOPT_SSL_VERIFYPEER, $this->ssl_verifypeer);
     curl_setopt($ci, CURLOPT_HEADERFUNCTION, array($this, 'getHeader'));
     curl_setopt($ci, CURLOPT_HEADER, FALSE);
     switch ($method) {
         case 'POST':
             curl_setopt($ci, CURLOPT_POST, TRUE);
             if ($authorization_header) {
                 $headers[] = $authorization_header;
             }
             if (!empty($postfields)) {
                 // print_r($postfields);
                 curl_setopt($ci, CURLOPT_POSTFIELDS, $postfields);
             }
             break;
         case 'DELETE':
             curl_setopt($ci, CURLOPT_CUSTOMREQUEST, 'DELETE');
             if (!empty($postfields)) {
                 $url = "{$url}?{$postfields}";
             }
     }
     //  echo '<pre>';
     //print_r($headers);
     curl_setopt($ci, CURLOPT_HTTPHEADER, $headers);
     curl_setopt($ci, CURLOPT_URL, $url);
     //  echo $url;
     $response = curl_exec($ci);
     $this->http_code = curl_getinfo($ci, CURLINFO_HTTP_CODE);
     if (!in_array($this->http_code, array(200, 201, 301))) {
         CWP_TOP_Core::addNotice("Connection error: " . htmlentities($response), 'error');
         return false;
     }
     $this->http_info = array_merge($this->http_info, curl_getinfo($ci));
     $this->url = $url;
     curl_close($ci);
     if ($this->cache) {
         $this->cacheFile($response, $this->cache_file_name);
     }
     return $response;
 }
    echo $network_name;
    ?>
_top_opt_interval"> <?php 
    _e("Interval", CWP_TEXTDOMAIN);
    ?>
 </label>
									<span class="description"> <?php 
    _e('Minimum time between shares (Hour/Hours), 0.4 can be used also.', CWP_TEXTDOMAIN);
    ?>
 </span>

								</div><!-- end .left -->
								<div class="right">

									<?php 
    CWP_TOP_Core::generateFieldType(array('id' => '14', 'name' => __('Minimum interval between shares', CWP_TEXTDOMAIN), 'type' => 'text', 'slug' => 'interval', 'option_value' => $cwp_top_global_schedule[$network_name . '_schedule_type_selected'] == 'each' ? $cwp_top_global_schedule[$network_name . '_top_opt_interval'] : '8', "available_pro" => "yes", 'option' => $network_name . '_top_opt_interval', 'description' => __('Minimum time between shares (Hour/Hours), 0.4 can be used also.', CWP_TEXTDOMAIN), 'options' => array()));
    ?>
								</div><!-- end .right -->
							</fieldset><!-- end .option -->

						 </div>

					 </div>
					 <div class="cwp-according-item <?php 
    if ($cwp_top_global_schedule[$network_name . '_schedule_type_selected'] == 'custom') {
        ?>
 active <?php 
    }
    ?>
" >
						 <div class="cwp-according-header cwp-populate-hidden-radio" data-hidden="<?php