Plugin Directory

Changeset 989112


Ignore:
Timestamp:
09/13/2014 02:00:37 PM (12 years ago)
Author:
amweiss98
Message:

version 3.12

Location:
wp-rss-multi-importer/trunk
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • wp-rss-multi-importer/trunk/css/styles.css

    r964637 r989112  
    11.wprss-input {
    2     background: none repeat scroll 0 0 #EAF2FA;
    3     margin-bottom: 20px;
    4     padding-bottom: 10px;
    5     padding-left: 10px;
    6     padding-top: 10px;
    7     width: 1020px;
    8 }
    9 
    10 .wprss-input p { line-height: 28px; }
     2    background: none repeat scroll 0 0 #EAF2FA;
     3    margin-bottom: 20px;
     4    padding-bottom: 10px;
     5    padding-left: 10px;
     6    padding-top: 10px;
     7    width: 1020px;
     8}
     9
     10.wprss-input p {
     11    line-height: 28px;
     12}
    1113
    1214.wprss-input label {
    13     float: left;
    14     width: 95px !important;
    15     font-weight:bold !important;
    16 }
    17    
     15    float: left;
     16    width: 95px !important;
     17    font-weight: bold !important;
     18}
     19
    1820.wprss-input input {
    19     height: 28px;
    20     margin-bottom: 0;
    21     padding: 0 0 0 5px;
    22     width: 400px;
    23 }
    24 
    25 .wprss-input .category_list{
    26     margin-left:10px;
    27 }
    28 
    29 .wprss-input .chk_feed{
    30     margin-left:10px;
    31     color:red !important;
    32 }
    33 
     21    height: 28px;
     22    margin-bottom: 0;
     23    padding: 0 0 0 5px;
     24    width: 400px;
     25}
     26
     27.wprss-input .category_list {
     28    margin-left: 10px;
     29}
     30
     31.wprss-input .chk_feed {
     32    margin-left: 10px;
     33    color: red !important;
     34}
    3435
    3536.rss-output p {
    36   margin-bottom: 0em;
    37 
    38 }
    39 
    40 .errorfld {
    41     border:1px solid red !important;
    42 }
    43 
    44 #errormsg{
    45     color:red;
    46     margin-left:10px;
    47     !important;
    48 }
    49 
    50 .addbutton{
    51     margin-left:510px;
    52 }
    53 
    54 .addCategory{
    55     margin-left:510px;
    56 }
    57 
    58 
    59 .save_warning{
    60     color:red !important;
    61 }
    62 
     37    margin-bottom: 0em;
     38
     39}
     40
     41.errorfld {
     42    border: 1px solid red !important;
     43}
     44
     45#errormsg {
     46    color: red;
     47    margin-left: 10px;
     48!important;
     49}
     50
     51.addbutton {
     52    margin-left: 510px;
     53}
     54
     55.addCategory {
     56    margin-left: 510px;
     57}
     58
     59.save_warning {
     60    color: red !important;
     61}
    6362
    6463#element_to_pop_up {
    65     background-color:#fff;
    66     border-radius:15px;
    67     color:#000;
    68     display:none;
    69     padding:20px;
    70     min-width:400px;
    71     min-height: 180px;
    72 max-width:450px;
    73 }
    74 .bClose{
    75     cursor:pointer;
    76     position:absolute;
    77     right:10px;
    78     top:5px;
    79 }
    80 
    81 .ftpost_head{
    82     float:left;
    83     margin-right:30px;
    84     margin-left:25px;
    85     font-weight:bold;
    86 }
    87 
    88 .ftpost_l{
    89     margin:10px;
    90     margin-right:50px;
    91 }
    92 .ftpost_r{
    93     margin:10px;
    94 }
    95 
    96 .info_titles{
    97 font-size:18px  !important;
    98 }
    99    
    100 p.info_text{
    101 border-bottom: 1px solid #DDDDDD;
    102 padding-bottom:8px;
    103    
    104 }
    105 
    106 .MP_box{
     64    background-color: #fff;
     65    border-radius: 15px;
     66    color: #000;
     67    display: none;
     68    padding: 20px;
     69    min-width: 400px;
     70    min-height: 180px;
     71    max-width: 450px;
     72}
     73
     74.bClose {
     75    cursor: pointer;
     76    position: absolute;
     77    right: 10px;
     78    top: 5px;
     79}
     80
     81.ftpost_head {
     82    float: left;
     83    margin-right: 30px;
     84    margin-left: 25px;
     85    font-weight: bold;
     86}
     87
     88.ftpost_l {
     89    margin: 10px;
     90    margin-right: 50px;
     91}
     92
     93.ftpost_r {
     94    margin: 10px;
     95}
     96
     97.info_titles {
     98    font-size: 18px !important;
     99}
     100
     101p.info_text {
     102    border-bottom: 1px solid #DDDDDD;
     103    padding-bottom: 8px;
     104
     105}
     106
     107.MP_box {
    107108    border: 1px solid #CCC;
    108109    border-radius: 25px 25px;
    109110    margin: 10px 0 10px 0;
    110     padding: 10px 15px; 
    111     background:#1F88C9;
    112    
    113 }
    114 .MP_title{
    115 color:white !important;
    116 text-align:center;
    117 }
    118 
    119 
    120 .activate_box{
     111    padding: 10px 15px;
     112    background: #1F88C9;
     113
     114}
     115
     116.MP_title {
     117    color: white !important;
     118    text-align: center;
     119}
     120
     121.activate_box {
    121122    border: 1px solid #CCC;
    122123    border-radius: 25px 25px;
    123124    margin: 10px 0 10px 0;
    124     padding: 10px 15px;
    125     background:#FF6600;
    126    
    127 }
    128 .activate_title{
    129 color:white !important;
    130 text-align:center;
    131 }
    132 
    133 .txtorange{
     125    padding: 10px 15px;
     126    background: #FF6600;
     127
     128}
     129
     130.activate_title {
     131    color: white !important;
     132    text-align: center;
     133}
     134
     135.txtorange {
    134136    color: #FF6600;
    135     font-size:15px;
    136     text-align:center;
    137 }
    138 
    139 .txtwhite{
     137    font-size: 15px;
     138    text-align: center;
     139}
     140
     141.txtwhite {
    140142    color: #FFFFFF;
    141     font-size:15px;
    142     text-align:center;
    143 }
    144 
    145 .default-list-name{
    146 
    147     margin-top:5px;
    148     margin-bottom:5px;
    149     clear:both;
    150 }
    151 .default-list-image{
    152     margin-bottom:10px;
    153     float:left;
    154 }
    155 
    156 .default-list-tags{
    157     float:left;
    158     margin-left:10px;
    159 }
    160 .default-tags-text{
    161     margin-left:80px;
    162     font-size:18px;
    163 
    164 }
    165 .default-image-text{
    166         font-size:18px;
    167         margin-left:100px;
    168        
    169 }
    170 
    171 .default-filter-text{
    172         font-size:18px;
    173         margin-left:90px;
    174        
    175 }
    176 .default-tags-text-more{
    177     margin-left:220px;
    178     font-size:12px;
    179 
    180 }
    181 .default-image-text-more{
    182         font-size:12px;
    183         margin-left:150px;
    184        
    185 }
    186 
    187 .default-tags-exclude-more{
    188         font-size:12px;
    189         margin-left:90px;
    190        
    191 }
    192 
    193 .default-tags-filter-more{
    194         font-size:12px;
    195         margin-left:130px;
    196        
    197 }
    198 
    199 .default-image-wrapper{
    200     margin-top:15px;
    201 }
    202 
    203 
    204 .button-delete-red{
     143    font-size: 15px;
     144    text-align: center;
     145}
     146
     147.default-list-name {
     148
     149    margin-top: 5px;
     150    margin-bottom: 5px;
     151    clear: both;
     152}
     153
     154.default-list-image {
     155    margin-bottom: 10px;
     156    float: left;
     157}
     158
     159.default-list-tags {
     160    float: left;
     161    margin-left: 10px;
     162}
     163
     164.default-tags-text {
     165    margin-left: 80px;
     166    font-size: 18px;
     167
     168}
     169
     170.default-image-text {
     171    font-size: 18px;
     172    margin-left: 100px;
     173
     174}
     175
     176.default-filter-text {
     177    font-size: 18px;
     178    margin-left: 90px;
     179
     180}
     181
     182.default-tags-text-more {
     183    margin-left: 220px;
     184    font-size: 12px;
     185
     186}
     187
     188.default-image-text-more {
     189    font-size: 12px;
     190    margin-left: 150px;
     191
     192}
     193
     194.default-tags-exclude-more {
     195    font-size: 12px;
     196    margin-left: 90px;
     197
     198}
     199
     200.default-tags-filter-more {
     201    font-size: 12px;
     202    margin-left: 130px;
     203
     204}
     205
     206.default-image-wrapper {
     207    margin-top: 15px;
     208}
     209
     210.button-delete-red {
    205211    background-color: #9B2124;
    206212    color: #FFFFFF;
    207      padding: 5px;
    208 }
    209 
    210 
    211 .button-fetch-green{
     213    padding: 5px;
     214}
     215
     216.button-fetch-green {
    212217    background-color: #B9C558;
    213218    color: #FFFFFF;
    214      padding: 5px;
    215     margin-left:80px;
    216 }
    217 
    218 
    219 .button-delete-feeds-red{
     219    padding: 5px;
     220    margin-left: 80px;
     221}
     222
     223.button-delete-feeds-red {
    220224    background-color: #9B2124;
    221225    color: #FFFFFF;
    222      padding: 5px;
    223     margin-left:80px;
    224 }
    225 
    226 
    227 p#vtip { width: 400px;display: none; position: absolute; padding: 10px; left: 5px; font-size: 1em; line-height: 1.5em; background-color: white; border: 6px solid #9aabb7; -moz-border-radius: 5px;border-radius: 5px; -webkit-border-radius: 5px; z-index: 9999}
    228 
     226    padding: 5px;
     227    margin-left: 80px;
     228}
     229
     230p#vtip {
     231    width: 400px;
     232    display: none;
     233    position: absolute;
     234    padding: 10px;
     235    left: 5px;
     236    font-size: 1em;
     237    line-height: 1.5em;
     238    background-color: white;
     239    border: 6px solid #9aabb7;
     240    -moz-border-radius: 5px;
     241    border-radius: 5px;
     242    -webkit-border-radius: 5px;
     243    z-index: 9999
     244}
    229245
    230246span.vtip {
    231     background: url("../css/images/q.png") no-repeat scroll 0 0 transparent;
    232     display: inline-block;
    233     height: 16px;
    234     margin: 0 10px 0 2px !important;
    235     opacity: 0.7;
    236     text-indent: -9999px;
    237     width: 16px;
    238 }
    239 
    240 
    241 
     247    background: url("../css/images/q.png") no-repeat scroll 0 0 transparent;
     248    display: inline-block;
     249    height: 16px;
     250    margin: 0 10px 0 2px !important;
     251    opacity: 0.7;
     252    text-indent: -9999px;
     253    width: 16px;
     254}
    242255
    243256div#rssmi-big-ajax-loader {
    244    
    245     display: none;
    246       margin: 0px 0px 0px -50px; /* left margin is half width of the div, to centre it */
    247       padding: 30px 10px 10px 10px;
    248       position: absolute;
    249       left: 40%;
    250       top: 125px;
    251       width: 150px;
    252       height: 150px;
    253       text-align: center;
    254       background: #e8e8e8 url("../css/images/big_ajax_loader.gif") no-repeat center center;
    255 
    256 }
    257 
    258 
     257
     258    display: none;
     259    margin: 0px 0px 0px -50px; /* left margin is half width of the div, to centre it */
     260    padding: 30px 10px 10px 10px;
     261    position: absolute;
     262    left: 40%;
     263    top: 125px;
     264    width: 150px;
     265    height: 150px;
     266    text-align: center;
     267    background: #e8e8e8 url("../css/images/big_ajax_loader.gif") no-repeat center center;
     268
     269}
    259270
    260271div#rssmi-ajax-loader {
    261    
    262     display: none;
    263       margin: 0px 0px 0px -50px; /* left margin is half width of the div, to centre it */
    264       padding: 30px 10px 10px 10px;
    265       position: absolute;
    266       left: 20%;
    267       top: -225px;
    268       width: 100px;
    269       height: 100px;
    270       text-align: center;
    271       z-index: 1000;
    272       background: #e8e8e8 url("../css/images/ajax-loader.gif") no-repeat center center;
    273 
    274 }
    275 
     272
     273    display: none;
     274    margin: 0px 0px 0px -50px; /* left margin is half width of the div, to centre it */
     275    padding: 30px 10px 10px 10px;
     276    position: absolute;
     277    left: 20%;
     278    top: -225px;
     279    width: 100px;
     280    height: 100px;
     281    text-align: center;
     282    z-index: 1000;
     283    background: #e8e8e8 url("../css/images/ajax-loader.gif") no-repeat center center;
     284
     285}
    276286
    277287div#rssmi-ajax-loader-delete-fetch {
    278    
    279     display: none;
    280       margin: 0px 0px 0px -50px; /* left margin is half width of the div, to centre it */
    281       padding: 30px 10px 10px 10px;
    282       position: absolute;
    283       left: 20%;
    284       top: -10px;
    285       width: 50px;
    286       height: 50px;
    287       text-align: center;
    288       z-index: 1000;
    289       background: #e8e8e8 url("../css/images/ajax-loader.gif") no-repeat center center;
    290 
    291 }
    292 
     288
     289    display: none;
     290    margin: 0px 0px 0px -50px; /* left margin is half width of the div, to centre it */
     291    padding: 30px 10px 10px 10px;
     292    position: absolute;
     293    left: 20%;
     294    top: -10px;
     295    width: 50px;
     296    height: 50px;
     297    text-align: center;
     298    z-index: 1000;
     299    background: #e8e8e8 url("../css/images/ajax-loader.gif") no-repeat center center;
     300
     301}
    293302
    294303div#rssmi-ajax-loader-center {
    295    
    296     display: none;
    297       margin: 0px 0px 0px -50px; /* left margin is half width of the div, to centre it */
    298       padding: 30px 10px 10px 10px;
    299       position: fixed;
    300       top: 60%;
    301       left: 50%;
    302       width: 50px;
    303       height: 50px;
    304       text-align: center;
    305       z-index: 1000;
    306       background: #e8e8e8 url("../css/images/ajax-loader.gif") no-repeat center center;
    307 
    308 }
    309 
    310 
    311 
    312 
    313 
    314 
     304
     305    display: none;
     306    margin: 0px 0px 0px -50px; /* left margin is half width of the div, to centre it */
     307    padding: 30px 10px 10px 10px;
     308    position: fixed;
     309    top: 60%;
     310    left: 50%;
     311    width: 50px;
     312    height: 50px;
     313    text-align: center;
     314    z-index: 1000;
     315    background: #e8e8e8 url("../css/images/ajax-loader.gif") no-repeat center center;
     316
     317}
    315318
    316319div.rssmi-upgrade {
    317     background-color: #fff;
    318     border-left: 4px solid #7ad03a;
    319     box-shadow: 0 1px 1px 0 rgba(0, 0, 0, 0.1);
    320     padding: 1px 12px;
    321 }
    322 
    323 
    324 #submitpost, #submitpost #major-publishing-actions
    325 {
    326     border:none !important;
    327     padding:0 0 0 0 !important;
    328     margin:0 0 0 0 !important;
    329     background-color:#FFFFFF !important;
    330 }
     320    background-color: #fff;
     321    border-left: 4px solid #7ad03a;
     322    box-shadow: 0 1px 1px 0 rgba(0, 0, 0, 0.1);
     323    padding: 1px 12px;
     324}
     325
     326#submitpost, #submitpost #major-publishing-actions {
     327    border: none !important;
     328    padding: 0 0 0 0 !important;
     329    margin: 0 0 0 0 !important;
     330    background-color: #FFFFFF !important;
     331}
     332
     333.icon32-posts-rssmi_feed,
     334.icon32-posts-rssmi_feed_item {
     335    background: transparent url('../images/RSSadmin32.png') no-repeat left top !important;
     336}
  • wp-rss-multi-importer/trunk/inc/admin_functions.php

    r976190 r989112  
    11<?php
    22
     3/**
     4 * Returns the saved or default date format
     5 *
     6 * @return string
     7 */
     8function rssmi_get_default_date_format() {
    39
    4 function rssmi_get_default_date_format(){
    5    
    6     $rssmi_global_options = get_option( 'rssmi_global_options' );
    7     if (!empty($rssmi_global_options)){
    8         $date_format=$rssmi_global_options['date_format']; 
    9     }else{
    10         $date_format="D, M d, Y";   
     10    $rssmi_global_options = get_option( 'rssmi_global_options' );
     11
     12    if ( ! empty( $rssmi_global_options ) ) {
     13        return $rssmi_global_options['date_format'];
    1114    }
    12     return $date_format;
     15    else {
     16        return "D, M d, Y";
     17    }
    1318}
    1419
     20/**
     21 * Update the last DB update option in the database to now
     22 */
     23function rssmi_update_feed_time() {
    1524
    16 
    17 function rssmi_update_feed_time(){
    18    
    19    
    20    
    21         $wprssmi_admin_options = get_option( 'rss_admin_options' );  // admin settings
    22         $wprssmi_admin_options['last_db_update'] = strtotime("now");
    23         update_option( 'rss_admin_options', $wprssmi_admin_options ); //put the current version in the database
    24        
    25        
    26 }
    27 
    28 function rssmi_show_last_feed_update(){
    29    
    30    
    31     $wprssmi_admin_options = get_option( 'rss_admin_options' );  // admin settings
    32     $last_db_update=$wprssmi_admin_options['last_db_update'];
    33 
    34 
    35     return "<br><div style='font-size:14px;'><strong>Last Update of the Feed Database on</strong> ".get_date_from_gmt(date('Y-m-d H:i:s',$last_db_update),'M j, Y @ g:i a  ').":          ".rssmi_long_ago($last_db_update)." ago<button type='button' name='getFeedsNow' id='getFeeds-Now' class='button-fetch-green' value=''>CLICK TO UPDATE THE FEED DATABASE NOW</button>&nbsp;&nbsp;&nbsp;&nbsp;(note: this could take several minutes)<div id='gfnote' style='margin-left:520px;'></div><div id='rssmi-ajax-loader-center'></div></div><p>Think there is a scheduling problem, <a href='http://www.wprssimporter.com/faqs/the-cron-scheduler-isnt-working-whats-happening/' target='_blank'>read this</a></p>";
    36    
    37 
     25    $wprssmi_admin_options                   = get_option( 'rss_admin_options' ); // admin settings
     26    $wprssmi_admin_options['last_db_update'] = time();
     27    update_option( 'rss_admin_options', $wprssmi_admin_options ); //put the current version in the database
    3828
    3929}
    4030
     31/**
     32 * Displays the last time the feed was updated and controls to update now
     33 *
     34 * @return string
     35 */
     36function rssmi_show_last_feed_update() {
    4137
    42 function rssmi_long_ago ($time)
    43 {
     38    $wprssmi_admin_options = get_option( 'rss_admin_options' ); // admin settings
     39    $last_db_update        = $wprssmi_admin_options['last_db_update'];
    4440
    45     $time = time() - $time; // to get the time since that moment
     41    return "
     42    <h3>Last Update of the Feed Database: <em>" .
     43        get_date_from_gmt( date( 'Y-m-d H:i:s', $last_db_update ), 'M j, Y @ g:i a' ) . "; " .
     44        human_time_diff( $last_db_update, time() ) . " ago</em></h3>
     45    <p><button type='button' name='getFeedsNow' id='getFeeds-Now' class='button button-primary' value=''>Update the feed Database</button></p>
    4646
    47     $tokens = array (
    48         31536000 => 'year',
    49         2592000 => 'month',
    50         604800 => 'week',
    51         86400 => 'day',
    52         3600 => 'hour',
    53         60 => 'minute',
    54         1 => 'second'
    55     );
    56 
    57     foreach ($tokens as $unit => $text) {
    58         if ($time < $unit) continue;
    59         $numberOfUnits = floor($time / $unit);
    60         return $numberOfUnits.' '.$text.(($numberOfUnits>1)?'s':'');
    61     }
     47    <div id='gfnote'>
     48        <em>(note: this could take several minutes)</em>
     49    </div>
     50    <div id='rssmi-ajax-loader-center'></div>
     51    <p>Think there is a scheduling problem? <a href='http://www.wprssimporter.com/faqs/the-cron-scheduler-isnt-working-whats-happening/' target='_blank'>Read this</a>.</p>";
    6252
    6353}
    6454
     55/**
     56 * Determines item freshness
     57 *
     58 * @param $date
     59 *
     60 * @return int
     61 */
     62function rssmi_is_not_fresh( $date ) {
     63    $rssmi_global_options = get_option( 'rssmi_global_options' );
     64    $days                 = round( abs( strtotime( $date ) - strtotime( 'now' ) ) / 86400 );
     65    if ( isset( $rssmi_global_options['item_freshness'] ) && $rssmi_global_options['item_freshness']>0 ) {
     66        $day_cutoff = $rssmi_global_options['item_freshness'];
    6567
    66 
    67 function rssmi_is_not_fresh($date){
    68     $rssmi_global_options = get_option( 'rssmi_global_options' );
    69     $days= round(abs(strtotime($date)-strtotime('now'))/86400);
    70     if (isset($rssmi_global_options['item_freshness'])){
    71         $day_cutoff= $rssmi_global_options['item_freshness'];   
    72        
    73             if ($days>=$day_cutoff){
    74                 return 1;
    75             }else{
    76                 return 0;
    77             }
    78     }else{
     68        if ( $days >= $day_cutoff ) {
     69            return 1;
     70        }
     71        else {
     72            return 0;
     73        }
     74    }
     75    else {
    7976        return 0;
    8077    }
    81    
    8278}
    83 
    84 
    85 
    86 ?>
  • wp-rss-multi-importer/trunk/inc/admin_init.php

    r964637 r989112  
    11<?php
    22
    3 
    4 
    5 
    6 
    7 
    8 
    9 add_action( 'admin_head', 'rssmi_custom_post_type_icon' );
    10 
    11 function rssmi_custom_post_type_icon() {
    12     ?>
    13     <style>
    14         /* Post Screen - 32px */
    15         .icon32-posts-rssmi_feed {
    16             background: transparent url( <?php echo WP_RSS_MULTI_IMAGES.'RSSadmin32.png'; ?> ) no-repeat left top !important;
    17         }
    18         /* Post Screen - 32px */
    19         .icon32-posts-rssmi_feed_item {
    20             background: transparent url( <?php echo WP_RSS_MULTI_IMAGES.'RSSadmin32.png'; ?> ) no-repeat left top !important;
    21         }   
    22     </style>
    23 <?php }
    24 
    25 //ON INIT
    26 
    27 add_action('admin_init','wp_rss_multi_importer_start');
    28 
    29 
    30 
    31 
    32 
    33 
    34 
    35 
    36 
    37 function wp_rss_multi_importer_start () {
     3/**
     4 * Admin init to add settings, styles, scripts
     5 */
     6function wp_rss_multi_importer_start() {
     7
     8    register_setting( 'wp_rss_multi_importer_options', 'rss_import_items' );
     9    register_setting( 'wp_rss_multi_importer_categories', 'rss_import_categories' );
     10    register_setting( 'wp_rss_multi_importer_item_options', 'rss_import_options' );
     11    register_setting( 'wp_rss_multi_importer_template_item', 'rss_template_item' );
     12    register_setting( 'wp_rss_multi_importer_feed_options', 'rss_feed_options' );
     13    register_setting( 'wp_rss_multi_importer_post_options', 'rss_post_options' );
     14    register_setting( 'wp_rss_multi_importer_admin_options', 'rss_admin_options' );
     15    register_setting( 'wp_rss_multi_importer_categories_images', 'rss_import_categories_images' );
     16    register_setting( 'wp_rss_multi_importer_global_options', 'rssmi_global_options', 'rssmi_sanitize_global' );
     17
     18    add_settings_section( 'wp_rss_multi_importer_main', '', 'wp_section_text', 'wprssimport' );
     19
     20    wp_enqueue_style( 'farbtastic' );
     21    wp_enqueue_script( 'farbtastic' );
     22
     23}
     24
     25add_action( 'admin_init', 'wp_rss_multi_importer_start' );
     26
     27
     28/**
     29 * Init function for the front-end auto-created posts
     30 */
     31function wp_rss_multi_importer_post_to_feed() {
     32
     33    $post_options = get_option( 'rss_post_options' );
     34
     35    if ( empty( $post_options ) ) {
     36        return;
     37    }
     38
     39    // Load colorbox scripts on the front end if the option is set
     40    if (
     41        empty( $post_options['targetWindow'] ) &&
     42        ( isset( $post_options['active'] ) && $post_options['active'] == 1 )
     43    ) {
     44        add_action( 'wp_footer', 'colorbox_scripts' );
     45    }
     46
     47    // Add noindex meta tags if the option is set
     48    if ( isset( $post_options['noindex'] ) && $post_options['noindex'] == 1 ) {
     49        add_action( 'wp_head', 'rssmi_noindex_function' );
     50    }
     51
     52    // Add canonical link if the option is set
     53    if ( isset( $post_options['addcanonical'] ) && $post_options['addcanonical'] == 1 ) {
     54        remove_action( 'wp_head', 'rel_canonical' );
     55        add_action( 'wp_head', 'rssmi_canonical_function' );
     56    }
     57}
     58
     59add_action( 'init', 'wp_rss_multi_importer_post_to_feed' );
     60
     61
     62/**
     63 * Is the current user on mobile?
     64 * TODO: update this from http://detectmobilebrowsers.com/
     65 *
     66 * @return int
     67 */
     68function rssmi_isMobile() {
     69    return preg_match( "/(android|avantgo|blackberry|bolt|boost|cricket|docomo|fone|hiptop|mini|mobi|palm|phone|pie|tablet|up\.browser|up\.link|webos|wos)/i", $_SERVER["HTTP_USER_AGENT"] );
     70}
     71
     72
     73/**
     74 * Set the global $isMobileDevice variable
     75 * TODO: stop using global variable and combine with the above
     76 *
     77 * @return int
     78 */
     79function isMobileForWordPress() {
     80
     81    global $isMobileDevice;
     82
     83    $isMobileDevice = rssmi_isMobile() ? 1 : 0;
     84
     85    return $isMobileDevice;
     86}
     87
     88add_action( 'init', 'isMobileForWordPress', 1 );
     89
     90
     91/**
     92 * Make sure SimplePie is loaded
     93 * TODO: why is this needed?
     94 */
     95function startSimplePie() {
     96    if ( ! class_exists( 'SimplePie' ) ) {
     97        require_once( ABSPATH . WPINC . '/class-simplepie.php' );
     98    }
     99
     100    class SimplePie_RSSMI extends SimplePie {
     101    }
     102}
     103
     104add_action( 'init', 'startSimplePie' );
     105
     106
     107/**
     108 * Setup all settings pages
     109 * TODO: Delete commented out pages here if not used
     110 * TODO: Update the menu icon to fit the new admin theme
     111 */
     112function wp_rss_multi_importer_menu() {
     113
     114    $menuColor   = rssmi_check_didUpgrade() == 1 ? "#2ea2cc" : "#F00";
     115    $parent_slug = 'wprssmi';
     116
     117    // Main menu page
     118    add_menu_page( __( 'Overview' ), __( 'Multi Importer' ), 'manage_options', $parent_slug, 'wp_rss_multi_importer_intro_page', WP_RSS_MULTI_IMAGES . "RSSadmin16.png", '150' );
     119
     120    // All submenu options pages
     121    add_submenu_page( $parent_slug, 'Start Here', '<span style="color:' . $menuColor . '">' . 'Start Here' . '</span>', 'manage_options', $parent_slug, 'wp_rss_multi_importer_intro_page', '', '' );
     122
     123    add_submenu_page( $parent_slug, 'Feed List', 'Feed List', 'manage_options', 'edit.php?post_type=rssmi_feed', '' );
    38124   
    39 register_setting('wp_rss_multi_importer_options', 'rss_import_items');
    40 register_setting('wp_rss_multi_importer_categories', 'rss_import_categories'); 
    41 register_setting('wp_rss_multi_importer_item_options', 'rss_import_options');   
    42 register_setting('wp_rss_multi_importer_template_item', 'rss_template_item');   
    43 register_setting('wp_rss_multi_importer_feed_options', 'rss_feed_options'); 
    44 register_setting('wp_rss_multi_importer_post_options', 'rss_post_options'); 
    45 register_setting('wp_rss_multi_importer_admin_options', 'rss_admin_options');
    46 register_setting('wp_rss_multi_importer_categories_images', 'rss_import_categories_images');
    47 register_setting('wp_rss_multi_importer_global_options', 'rssmi_global_options','rssmi_sanitize_global');
    48      
    49 add_settings_section( 'wp_rss_multi_importer_main', '', 'wp_section_text', 'wprssimport' ); 
    50 
    51 }
    52 
    53 add_action('admin_init', 'rssmi_ilc_farbtastic_script');
    54 
    55 function rssmi_ilc_farbtastic_script() {
    56   wp_enqueue_style( 'farbtastic' );
    57   wp_enqueue_script( 'farbtastic' );
    58 }
    59 
    60 
    61 
    62 add_action('init', 'wp_rss_multi_importer_post_to_feed');
    63 
    64 function wp_rss_multi_importer_post_to_feed(){
    65   $post_options = get_option('rss_post_options');
    66     if (!empty($post_options)) {
    67         if ($post_options['targetWindow']==0 && (isset($post_options['active']) && $post_options['active']==1)){
    68             add_action('wp_footer','colorbox_scripts');
    69         }
    70         if ($post_options['noindex']==1){
    71             add_action('wp_head', 'rssmi_noindex_function');
    72         }
    73             if (isset($post_options['addcanonical']) && $post_options['addcanonical']==1){
    74                 remove_action('wp_head', 'rel_canonical');
    75                 add_action('wp_head', 'rssmi_canonical_function');
    76             }
    77     }
    78 }
    79 
    80 
    81 
    82 function rssmi_isMobile() {
    83     return preg_match("/(android|avantgo|blackberry|bolt|boost|cricket|docomo|fone|hiptop|mini|mobi|palm|phone|pie|tablet|up\.browser|up\.link|webos|wos)/i", $_SERVER["HTTP_USER_AGENT"]);
    84 }
    85 
    86 function isMobileForWordPress() {
    87     global $isMobileDevice;
    88     if(rssmi_isMobile()){
    89        $isMobileDevice=1;
    90         }else{
    91             $isMobileDevice=0;
    92         }
    93         return $isMobileDevice;
    94 }
    95 
    96 add_action('init', 'isMobileForWordPress', 1);
    97 
    98 
    99 function startSimplePie(){
    100     if(! class_exists('SimplePie')){
    101                 require_once(ABSPATH . WPINC . '/class-simplepie.php');
    102     }
    103 
    104     class SimplePie_RSSMI extends SimplePie {} 
    105 
     125    add_submenu_page( $parent_slug, 'Add a Feed', 'Add a Feed', 'edit_posts', 'post-new.php?post_type=rssmi_feed', '' );
     126
     127    add_submenu_page( $parent_slug, 'Upload Feeds', 'Upload Feeds', 'manage_options', 'wprssmi_options8', 'wp_rss_multi_importer_upload_page' );
     128
     129    add_submenu_page( $parent_slug, 'Categories', 'Categories', 'manage_options', 'wprssmi_options', 'rssmi_category_pages', '' );
    106130   
    107 }
    108 add_action('init', 'startSimplePie');
    109 
    110 
    111 
    112 
    113 //  The main admin menu system
    114 
    115 add_action('admin_menu','wp_rss_multi_importer_menu');
    116 
    117 function wp_rss_multi_importer_menu () {
    118     $x=1;
    119     if (rssmi_check_didUpgrade()==1){
    120             $menuColor="#2ea2cc";
    121     }else{
    122             $menuColor=" #F00";
    123     }
    124 
    125    
    126    
    127     add_menu_page(__('Overview'), __('Multi Importer'), 'manage_options', 'wprssmi', 'wp_rss_multi_importer_intro_page', WP_RSS_MULTI_IMAGES."RSSadmin16.png", '150');
    128    
    129     add_submenu_page('wprssmi', 'Start Here','<span style="color:'.$menuColor.'">'.'Start Here'.'</span>', 'manage_options', 'wprssmi', 'wp_rss_multi_importer_intro_page', '', '');
    130 
    131 //  add_submenu_page('wprssmi', 'Start Here','<span style="color:#2ea2cc">'.'Start Here'.'</span>', 'manage_options', 'wprssmi', 'wp_rss_multi_importer_intro_page', '', '');
    132 
    133     add_submenu_page( 'wprssmi', 'Feed List', 'Feed List', 'manage_options', 'edit.php?post_type=rssmi_feed', '' );
    134 
    135     add_submenu_page( 'wprssmi', 'Add a Feed', 'Add a Feed', 'edit_posts', 'post-new.php?post_type=rssmi_feed', '' );
    136    
    137     add_submenu_page( 'wprssmi', 'Upload Feeds', 'Upload Feeds', 'manage_options', 'wprssmi_options8', 'wp_rss_multi_importer_upload_page' );
    138     add_submenu_page( 'wprssmi', 'Categories', 'Categories', 'manage_options', 'wprssmi_options', 'rssmi_category_pages','' ); 
    139    
    140         add_submenu_page( 'wprssmi', 'Feed Items', 'Feed Items', 'edit_posts', 'edit.php?post_type=rssmi_feed_item', '' );
    141             add_submenu_page( 'wprssmi', 'Global Settings', 'Global Settings', 'manage_options', 'wprssmi_options5', 'wp_rss_multi_importer_dateformat_page' );
    142    
    143     add_submenu_page( 'wprssmi', 'AutoPost', 'AutoPost', 'manage_options', 'wprssmi_options3', 'wp_rss_multi_importer_display_autopost' ); 
    144    
    145    
    146     add_submenu_page( 'wprssmi', 'Shortcode', 'Shortcode', 'manage_options', 'wprssmi_options2', 'wp_rss_multi_importer_display_shortcode' );
    147      
    148 
    149    
    150    
    151    
    152 //  add_submenu_page( 'wprssmi', 'Settings', '<span style="color:#2ea2cc">'.'Settings'.'</span>', 'manage_options', 'wprssmi_options2', 'wp_rss_multi_importer_display' );
    153    
    154 //  add_submenu_page( 'wprssmi', 'Shortcode Parameters', 'Shortcode Parameters', 'manage_options', 'wprssmi_options6', 'wp_rss_multi_importer_style_tags' ); 
    155    
    156 //  add_submenu_page( 'wprssmi', 'Shortcode Settings', 'Shortcode Settings', 'manage_options', 'wprssmi_options2', 'wp_rss_multi_importer_options_page' );   
    157    
    158 //  add_submenu_page( 'wprssmi', 'Manage AutoPosts', 'Manage AutoPosts', 'manage_options', 'wprssmi_options4', 'rssmi_posts_list' );
    159    
    160 
    161 
    162 
    163 
    164    
    165     add_submenu_page( 'wprssmi', 'Export', 'Export Feeds', 'manage_options', 'wprssmi_options7', 'wp_rss_multi_importer_feed_page' );
    166    
    167    
    168 
    169    
    170     add_submenu_page( 'wprssmi', 'Diagnostics', 'Diagnostics', 'manage_options', 'wprssmi_options9', 'wp_rss_multi_importer_diagnostics' );
    171    
    172 
    173        
    174    
    175 }
    176 
    177 
    178 function rssmi_category_pages(){
    179    
    180         wp_rss_multi_importer_category_page();
     131    add_submenu_page( $parent_slug, 'Feed Items', 'Feed Items', 'edit_posts', 'edit.php?post_type=rssmi_feed_item', '' );
     132
     133    add_submenu_page( $parent_slug, 'Global Settings', 'Global Settings', 'manage_options', 'wprssmi_options5', 'wp_rss_multi_importer_dateformat_page' );
     134
     135    add_submenu_page( $parent_slug, 'AutoPost', 'AutoPost', 'manage_options', 'wprssmi_options3', 'wp_rss_multi_importer_display_autopost' );
     136
     137    add_submenu_page( $parent_slug, 'Shortcode', 'Shortcode', 'manage_options', 'wprssmi_options2', 'wp_rss_multi_importer_display_shortcode' );
     138
     139    add_submenu_page( $parent_slug, 'Export', 'Export Feeds', 'manage_options', 'wprssmi_options7', 'wp_rss_multi_importer_feed_page' );
     140
     141    add_submenu_page( $parent_slug, 'Diagnostics', 'Diagnostics', 'manage_options', 'wprssmi_options9', 'wp_rss_multi_importer_diagnostics' );
     142
     143    // All submenu Feed Items pages
     144
     145
     146
     147    //  add_submenu_page( 'wprssmi', 'Settings', '<span style="color:#2ea2cc">'.'Settings'.'</span>', 'manage_options', 'wprssmi_options2', 'wp_rss_multi_importer_display' );
     148
     149    //  add_submenu_page( 'wprssmi', 'Shortcode Parameters', 'Shortcode Parameters', 'manage_options', 'wprssmi_options6', 'wp_rss_multi_importer_style_tags' );
     150
     151    //  add_submenu_page( 'wprssmi', 'Shortcode Settings', 'Shortcode Settings', 'manage_options', 'wprssmi_options2', 'wp_rss_multi_importer_options_page' );
     152
     153    //  add_submenu_page( 'wprssmi', 'Manage AutoPosts', 'Manage AutoPosts', 'manage_options', 'wprssmi_options4', 'rssmi_posts_list' );
     154
     155    //  add_submenu_page('wprssmi', 'Start Here','<span style="color:#2ea2cc">'.'Start Here'.'</span>', 'manage_options', 'wprssmi', 'wp_rss_multi_importer_intro_page', '', '');
     156
     157
     158}
     159
     160add_action( 'admin_menu', 'wp_rss_multi_importer_menu' );
     161
     162
     163/**
     164 * Output Feed category options page
     165 */
     166function rssmi_category_pages() {
     167    wp_rss_multi_importer_category_page();
    181168    wp_rss_multi_importer_category_images_page();
    182169}
    183170
    184 function rssmi_posts_list(){
     171
     172/**
     173 * Output Manage Auto Post page
     174 */
     175function rssmi_posts_list() {
    185176    global $myListTable;
    186177    my_add_menu_items();
    187178    rssmi_add_options();
    188 //  add_options();
    189179    my_render_list_page();
    190180    $myListTable->admin_header();
     
    192182
    193183
     184/**
     185 * Output Auto Post settings page tabs
     186 *
     187 * @param string $active_tab
     188 */
    194189function wp_rss_multi_importer_display_autopost( $active_tab = '' ) {
    195        
    196 ?>
    197    
     190
     191    // Set default active tab if URL parameter is not set
     192    if ( empty( $active_tab ) ) {
     193        if ( isset( $_GET['tab'] ) ) {
     194            $active_tab = $_GET['tab'];
     195        } else {
     196            $active_tab = 'feed_to_post_options';
     197        }
     198    }
     199
     200    ?>
     201
    198202    <div class="wrap">
    199    
     203
    200204        <div id="icon-themes" class="icon32"></div>
    201         <h2><?php  _e("Multi-Importer", 'wp-rss-multi-importer')?></h2>
    202         <?php //settings_errors(); ?>
    203        
    204         <?php if( isset( $_GET[ 'tab' ] ) ) {
    205             $active_tab = $_GET[ 'tab' ];
    206         } else if( $active_tab == 'feed_to_post_options' ) {
    207                     $active_tab = 'feed_to_post_options';
    208         } else if( $active_tab == 'manage_autoposts' ) {
    209                 $active_tab = 'manage_autoposts';
    210         } else { $active_tab = 'feed_to_post_options'; 
    211            
    212         } // end if/else ?>
    213        
     205        <h2><?php _e( "Multi-Importer", 'wp-rss-multi-importer' ) ?></h2>
     206
    214207        <!-- AutoPost menu  -->
    215        
     208
    216209        <h2 class="nav-tab-wrapper">
    217                 <a href="?page=wprssmi_options3&tab=feed_to_post_options" class="nav-tab <?php echo $active_tab == 'feed_to_post_options' ? 'nav-tab-active' : ''; ?>"><?php  _e("AutoPost Settings", 'wp-rss-multi-importer')?></a>
    218                     <a href="?page=wprssmi_options3&tab=manage_autoposts" class="nav-tab <?php echo $active_tab == 'manage_autoposts' ? 'nav-tab-active' : ''; ?>"><?php  _e("Manage AutoPosts", 'wp-rss-multi-importer')?></a>
    219                
     210            <a href="?page=wprssmi_options3&tab=feed_to_post_options" class="nav-tab <?php echo $active_tab == 'feed_to_post_options' ? 'nav-tab-active' : ''; ?>"><?php _e( "AutoPost Settings", 'wp-rss-multi-importer' ) ?></a>
     211            <a href="?page=wprssmi_options3&tab=manage_autoposts" class="nav-tab <?php echo $active_tab == 'manage_autoposts' ? 'nav-tab-active' : ''; ?>"><?php _e( "Manage AutoPosts", 'wp-rss-multi-importer' ) ?></a>
    220212        </h2>
    221        
    222        
    223        
    224 
    225             <?php
    226            
    227                 if ( $active_tab == 'feed_to_post_options' ) {
    228 
     213
     214        <?php
     215        switch ( $active_tab ) {
     216            case 'feed_to_post_options':
    229217                wp_rss_multi_importer_post_page();
    230                
    231                 } else if ( $active_tab == 'manage_autoposts' ) {
    232 
    233                
    234                
    235            
    236            
    237             rssmi_posts_list();
    238        
    239            
    240         } else if ( $active_tab == 'feed_to_post_options' ) {
    241                
    242             wp_rss_multi_importer_options_page();
    243        
    244             } else if ( $active_tab == 'category_options' ) {
    245 
     218                break;
     219            case 'manage_autoposts':
     220                rssmi_posts_list();
     221                break;
     222            case 'category_options':
    246223                wp_rss_multi_importer_category_page();
    247             wp_rss_multi_importer_category_images_page();
    248            
    249             } else if ( $active_tab == 'more_options' ) {
    250                
    251                 wp_rss_multi_importer_dateformat_page();   
    252                
    253                 } else {
    254             wp_rss_multi_importer_options_page();
    255                    
    256                
    257                 } // end if/else   
    258                
    259                
    260            
    261             ?>
     224                wp_rss_multi_importer_category_images_page();
     225                break;
     226            case 'more_options':
     227                wp_rss_multi_importer_dateformat_page();
     228                break;
     229            default:
     230                wp_rss_multi_importer_options_page();
     231        }
     232        ?>
    262233    </div>
    263    
    264 <?php
    265 }
    266 
    267 
    268 
     234    <?php
     235}
     236
     237
     238/**
     239 * Output shortcode options page
     240 *
     241 * @param string $active_tab
     242 */
    269243function wp_rss_multi_importer_display_shortcode( $active_tab = '' ) {
    270        
    271 ?>
    272    
     244
     245    // Set default active tab if URL parameter is not set
     246    if ( empty( $active_tab ) ) {
     247        if ( isset( $_GET['tab'] ) ) {
     248            $active_tab = $_GET['tab'];
     249        }
     250        else {
     251            $active_tab = 'setting_options';
     252        }
     253    }
     254
     255    ?>
     256
    273257    <div class="wrap">
    274        
     258
    275259        <div id="icon-themes" class="icon32"></div>
    276         <h2><?php  _e("Multi-Importer", 'wp-rss-multi-importer')?></h2>
    277         <?php //settings_errors(); ?>
    278        
    279         <?php if( isset( $_GET[ 'tab' ] ) ) {
    280             $active_tab = $_GET[ 'tab' ];
    281         } else if( $active_tab == 'setting_options' ) {
    282                     $active_tab = 'setting_options';
    283         } else if( $active_tab == 'shortcode_parameters' ) {
    284                 $active_tab = 'shortcode_parameters';
    285             } else if( $active_tab == 'save_template' ) {
    286                     $active_tab = 'save_template';
    287         } else { $active_tab = 'setting_options';   
    288            
    289         } // end if/else ?>
    290        
     260        <h2><?php _e( "Multi-Importer", 'wp-rss-multi-importer' ) ?></h2>
     261
    291262        <!-- AutoPost menu  -->
    292        
     263
    293264        <h2 class="nav-tab-wrapper">
    294                 <a href="?page=wprssmi_options2&tab=setting_options" class="nav-tab <?php echo $active_tab == 'setting_options' ? 'nav-tab-active' : ''; ?>"><?php  _e("Shortcode Settings", 'wp-rss-multi-importer')?></a>
    295                     <a href="?page=wprssmi_options2&tab=shortcode_parameters" class="nav-tab <?php echo $active_tab == 'shortcode_parameters' ? 'nav-tab-active' : ''; ?>"><?php  _e("Shortcode Parameters", 'wp-rss-multi-importer')?></a>
    296                                
    297         <a href="?page=wprssmi_options2&tab=save_template" class="nav-tab <?php echo $active_tab == 'save_template' ? 'nav-tab-active' : ''; ?>"><?php  _e("Save Template and CSS", 'wp-rss-multi-importer')?></a>
    298        
     265            <a href="?page=wprssmi_options2&tab=setting_options" class="nav-tab <?php echo $active_tab == 'setting_options' ? 'nav-tab-active' : ''; ?>"><?php _e( "Shortcode Settings", 'wp-rss-multi-importer' ) ?></a>
     266            <a href="?page=wprssmi_options2&tab=shortcode_parameters" class="nav-tab <?php echo $active_tab == 'shortcode_parameters' ? 'nav-tab-active' : ''; ?>"><?php _e( "Shortcode Parameters", 'wp-rss-multi-importer' ) ?></a>
     267
     268            <a href="?page=wprssmi_options2&tab=save_template" class="nav-tab <?php echo $active_tab == 'save_template' ? 'nav-tab-active' : ''; ?>"><?php _e( "Save Template and CSS", 'wp-rss-multi-importer' ) ?></a>
    299269        </h2>
    300        
    301 
    302 
    303             <?php
    304            
    305                 if ( $active_tab == 'setting_options' ) {
    306 
     270
     271        <?php
     272        switch ( $active_tab ) {
     273            case 'setting_options':
    307274                wp_rss_multi_importer_options_page();
    308                
    309                 } else if ( $active_tab == 'shortcode_parameters' ) {
    310 
     275                break;
     276            case 'shortcode_parameters':
    311277                wp_rss_multi_importer_style_tags();
    312                
    313                 } else if ( $active_tab == 'save_template' ) {
    314 
     278                break;
     279            case 'save_template':
    315280                wp_rss_multi_importer_template_page();
    316 
    317                
    318                 } else {
    319             wp_rss_multi_importer_options_page();
    320                    
    321                
    322                 } // end if/else   
    323                
    324                
    325            
    326             ?>
     281                break;
     282            default:
     283                wp_rss_multi_importer_options_page();
     284        }
     285        ?>
    327286    </div>
    328    
    329 <?php
    330 }
    331 
    332 
    333 
    334 
    335 
    336 ?>
     287    <?php
     288}
  • wp-rss-multi-importer/trunk/inc/cron.php

    r976544 r989112  
    11<?php
    22
    3 
    4 add_action('init', 'wp_rss_multi_activation');
    5 
    6 
     3/**
     4 * Create cron events
     5 */
    76function wp_rss_multi_activation() {
    8    
    9     if ( !wp_next_scheduled( 'wp_rss_multi_event' ) ) {
    10         wp_schedule_event( time(), 'hourly', 'wp_rss_multi_event');
    11     }
    12    
    13     if ( !wp_next_scheduled( 'wp_rss_multi_event_delete_custom_posts' ) ) {
    14         wp_schedule_event( time(), 'hourly', 'wp_rss_multi_event_delete_custom_posts');
    15     }
    16    
    17 }
    18 
    19 add_action('wp_rss_multi_event', 'wp_rss_multi_cron');
    20 add_action('wp_rss_multi_event_delete_custom_posts', 'wp_rss_multi_delete_custom_posts');
    21 
    22 
    23 
    24 
    25 add_action('init', 'rssmi_schedule_autopost'); 
    26 
    27 function rssmi_schedule_autopost(){
    28    
    29     $post_schedule_options = get_option('rss_post_options');
    30         if(isset($post_schedule_options['active']) && $post_schedule_options['active']==1 ){
    31            
    32             if (isset($post_schedule_options['fetch_schedule'])){
    33                     $periodnumber=$post_schedule_options['fetch_schedule'];
    34                 }else{
    35                     $periodnumber = 1;
    36             }
    37 
    38         switch ($periodnumber) {
    39             case 1: $display_period='hourly'; break;
    40             case 2: $display_period='tenminutes'; break;
    41             case 3: $display_period='fifteenminutes'; break;
    42             case 4: $display_period='twentyminutes'; break;
    43             case 5: $display_period='thirtyminutes'; break;
    44             case 6: $display_period='twohours'; break;
    45             case 7: $display_period='fourhours'; break;
    46             case 12: $display_period='twicedaily'; break;
    47             case 24: $display_period='daily'; break;
    48             case 168: $display_period='weekly'; break;
    49         }   
    50                    
    51 
    52    
    53     if( !wp_next_scheduled( 'wp_rss_multi_event_feedtopost' ) ){
    54          wp_schedule_event( time(), $display_period, 'wp_rss_multi_event_feedtopost' );
    55       }
    56    
    57     add_action('wp_rss_multi_event_feedtopost', 'wp_rss_multi_cron_feedtopost');
    58    
    59     }else{
    60         wp_rss_multi_deactivation(2);
    61     }
    62 }
    63 
    64 
    65 
    66 add_action('init', 'rssmi_schedule_import_feeds'); 
    67 
    68 function rssmi_schedule_import_feeds(){
    69 
    70         $rssmi_global_options = get_option( 'rssmi_global_options' );
    71        
    72            
    73             if (isset($rssmi_global_options['fetch_schedule'])){
    74                     $feedperiodnumber=$rssmi_global_options['fetch_schedule'];
    75                 }else{
    76                     $feedperiodnumber = 1;
    77             }
    78 
    79         switch ($feedperiodnumber) {
    80             case 1: $feed_display_period='hourly'; break;
    81             case 2: $feed_display_period='tenminutes'; break;
    82             case 3: $feed_display_period='fifteenminutes'; break;
    83             case 4: $feed_display_period='twentyminutes'; break;
    84             case 5: $feed_display_period='thirtyminutes'; break;
    85             case 6: $display_period='twohours'; break;
    86             case 7: $display_period='fourhours'; break;
    87             case 12: $feed_display_period='twicedaily'; break;
    88             case 24: $feed_display_period='daily'; break;
    89             case 168: $feed_display_period='weekly'; break;
    90         }   
    91        
    92 
    93             $current_schedule=wp_get_schedule('wp_rss_multi_event_importfeeds');
    94 
    95             if ($current_schedule!=$feed_display_period){wp_clear_scheduled_hook('wp_rss_multi_event_importfeeds');}
    96 
    97 
    98 
    99    
    100     if( !wp_next_scheduled( 'wp_rss_multi_event_importfeeds' ) ){
    101          wp_schedule_event( time(), $feed_display_period, 'wp_rss_multi_event_importfeeds' );
    102       }
    103    
    104     add_action('wp_rss_multi_event_importfeeds', 'wp_rss_multi_cron_importfeeds');
    105 }
    106 
    107 
    108 
    109 
    110 
    111 
    112 
    113 
    114 
     7
     8    if ( ! wp_next_scheduled( 'wp_rss_multi_event' ) ) {
     9        wp_schedule_event( time(), 'hourly', 'wp_rss_multi_event' );
     10    }
     11
     12    if ( ! wp_next_scheduled( 'wp_rss_multi_event_delete_custom_posts' ) ) {
     13        wp_schedule_event( time(), 'hourly', 'wp_rss_multi_event_delete_custom_posts' );
     14    }
     15
     16}
     17
     18add_action( 'init', 'wp_rss_multi_activation' );
     19
     20
     21/**
     22 * Setup additional cron schedule for Auto Post
     23 */
     24function rssmi_schedule_autopost() {
     25
     26    $post_schedule_options = get_option( 'rss_post_options' );
     27    if ( isset( $post_schedule_options['active'] ) && $post_schedule_options['active'] == 1 ) {
     28
     29        if ( isset( $post_schedule_options['fetch_schedule'] ) ) {
     30            $periodnumber = $post_schedule_options['fetch_schedule'];
     31        }
     32        else {
     33            $periodnumber = 1;
     34        }
     35
     36        switch ( $periodnumber ) {
     37            case 1:
     38                $display_period = 'hourly';
     39                break;
     40            case 2:
     41                $display_period = 'tenminutes';
     42                break;
     43            case 3:
     44                $display_period = 'fifteenminutes';
     45                break;
     46            case 4:
     47                $display_period = 'twentyminutes';
     48                break;
     49            case 5:
     50                $display_period = 'thirtyminutes';
     51                break;
     52            case 6:
     53                $display_period = 'twohours';
     54                break;
     55            case 7:
     56                $display_period = 'fourhours';
     57                break;
     58            case 12:
     59                $display_period = 'twicedaily';
     60                break;
     61            case 24:
     62                $display_period = 'daily';
     63                break;
     64            case 168:
     65                $display_period = 'weekly';
     66                break;
     67            default:
     68                $display_period = 'weekly';
     69        }
     70
     71
     72        if ( ! wp_next_scheduled( 'wp_rss_multi_event_feedtopost' ) ) {
     73            wp_schedule_event( time(), $display_period, 'wp_rss_multi_event_feedtopost' );
     74        }
     75
     76        add_action( 'wp_rss_multi_event_feedtopost', 'wp_rss_multi_cron_feedtopost' );
     77
     78    }
     79    else {
     80        wp_rss_multi_deactivation( 2 );
     81    }
     82}
     83
     84add_action( 'init', 'rssmi_schedule_autopost' );
     85
     86
     87/**
     88 * Setup additional cron schedule for Feed Imports
     89 */
     90function rssmi_schedule_import_feeds() {
     91
     92    $rssmi_global_options = get_option( 'rssmi_global_options' );
     93
     94    if ( isset( $rssmi_global_options['fetch_schedule'] ) ) {
     95        $feedperiodnumber = $rssmi_global_options['fetch_schedule'];
     96    }
     97    else {
     98        $feedperiodnumber = 1;
     99    }
     100
     101    $feed_display_period = '';
     102    switch ( $feedperiodnumber ) {
     103        case 1:
     104            $feed_display_period = 'hourly';
     105            break;
     106        case 2:
     107            $feed_display_period = 'tenminutes';
     108            break;
     109        case 3:
     110            $feed_display_period = 'fifteenminutes';
     111            break;
     112        case 4:
     113            $feed_display_period = 'twentyminutes';
     114            break;
     115        case 5:
     116            $feed_display_period = 'thirtyminutes';
     117            break;
     118        case 6:
     119            $feed_display_period = 'twohours';
     120            break;
     121        case 7:
     122            $feed_display_period = 'fourhours';
     123            break;
     124        case 12:
     125            $feed_display_period = 'twicedaily';
     126            break;
     127        case 24:
     128            $feed_display_period = 'daily';
     129            break;
     130        case 168:
     131            $feed_display_period = 'weekly';
     132            break;
     133    }
     134
     135    $current_schedule = wp_get_schedule( 'wp_rss_multi_event_importfeeds' );
     136
     137    if ( $current_schedule != $feed_display_period ) {
     138        wp_clear_scheduled_hook( 'wp_rss_multi_event_importfeeds' );
     139    }
     140
     141    if ( ! wp_next_scheduled( 'wp_rss_multi_event_importfeeds' ) ) {
     142        wp_schedule_event( time(), $feed_display_period, 'wp_rss_multi_event_importfeeds' );
     143    }
     144
     145    add_action( 'wp_rss_multi_event_importfeeds', 'wp_rss_multi_cron_importfeeds' );
     146}
     147
     148add_action( 'init', 'rssmi_schedule_import_feeds' );
     149
     150
     151/**
     152 * Add a weekly schedule to cron
     153 *
     154 * @param $schedules
     155 *
     156 * @return mixed
     157 */
     158function cron_add_wprssmi_schedule( $schedules ) {
     159
     160    $period              = 168 * 3600;
     161    $schedules['weekly'] = array(
     162        'interval' => $period,
     163        'display'  => __( 'Once Weekly' )
     164    );
     165    return $schedules;
     166}
    115167
    116168add_filter( 'cron_schedules', 'cron_add_wprssmi_schedule' );
    117169
    118 function cron_add_wprssmi_schedule( $schedules ) {  //add a weekly schedule to cron
    119    
    120     $period=168*3600;
    121     $schedules['weekly'] = array(
    122         'interval' => $period,
    123         'display' => __( 'Once Weekly' )
    124     );
    125     return $schedules; 
    126 }
    127 
    128 
     170
     171/**
     172 * Add a 10 min schedule to cron
     173 *
     174 * @param $schedules
     175 *
     176 * @return mixed
     177 */
     178function cron_add_wprssmi_schedule_10( $schedules ) {
     179
     180    $period                  = 600;
     181    $schedules['tenminutes'] = array(
     182        'interval' => $period,
     183        'display'  => __( 'Once Every 10 Minutes' )
     184    );
     185    return $schedules;
     186}
    129187
    130188add_filter( 'cron_schedules', 'cron_add_wprssmi_schedule_10' );
    131189
    132 function cron_add_wprssmi_schedule_10( $schedules ) {  //add a 10 min schedule to cron
    133    
    134     $period=600;
    135     $schedules['tenminutes'] = array(
    136         'interval' => $period,
    137         'display' => __( 'Once Every 10 Minutes' )
    138     );
    139     return $schedules; 
    140 }
    141 
     190
     191/**
     192 * Add a 15 min schedule to cron
     193 *
     194 * @param $schedules
     195 *
     196 * @return mixed
     197 */
     198function cron_add_wprssmi_schedule_15( $schedules ) {
     199
     200    $period                      = 900;
     201    $schedules['fifteenminutes'] = array(
     202        'interval' => $period,
     203        'display'  => __( 'Once Every 15 Minutes' )
     204    );
     205    return $schedules;
     206}
    142207
    143208add_filter( 'cron_schedules', 'cron_add_wprssmi_schedule_15' );
    144209
    145 function cron_add_wprssmi_schedule_15( $schedules ) {  //add a 15 min schedule to cron
    146    
    147     $period=900;
    148     $schedules['fifteenminutes'] = array(
    149         'interval' => $period,
    150         'display' => __( 'Once Every 15 Minutes' )
    151     );
    152     return $schedules; 
    153 }
    154 
     210
     211/**
     212 * Add a 20 min schedule to cron
     213 *
     214 * @param $schedules
     215 *
     216 * @return mixed
     217 */
     218function cron_add_wprssmi_schedule_20( $schedules ) {
     219
     220    $period                     = 1200;
     221    $schedules['twentyminutes'] = array(
     222        'interval' => $period,
     223        'display'  => __( 'Once Every 20 Minutes' )
     224    );
     225    return $schedules;
     226}
    155227
    156228add_filter( 'cron_schedules', 'cron_add_wprssmi_schedule_20' );
    157229
    158 function cron_add_wprssmi_schedule_20( $schedules ) {  //add a 20 min schedule to cron
    159    
    160     $period=1200;
    161     $schedules['twentyminutes'] = array(
    162         'interval' => $period,
    163         'display' => __( 'Once Every 20 Minutes' )
    164     );
    165     return $schedules; 
    166 }
    167 
     230
     231/**
     232 * Add a 30 min schedule to cron
     233 *
     234 * @param $schedules
     235 *
     236 * @return mixed
     237 */
     238function cron_add_wprssmi_schedule_30( $schedules ) {
     239
     240    $period                     = 1800;
     241    $schedules['thirtyminutes'] = array(
     242        'interval' => $period,
     243        'display'  => __( 'Once Every 30 Minutes' )
     244    );
     245    return $schedules;
     246}
    168247
    169248add_filter( 'cron_schedules', 'cron_add_wprssmi_schedule_30' );
    170249
    171 function cron_add_wprssmi_schedule_30( $schedules ) {  //add a 30 min schedule to cron
    172    
    173     $period=1800;
    174     $schedules['thirtyminutes'] = array(
    175         'interval' => $period,
    176         'display' => __( 'Once Every 30 Minutes' )
    177     );
    178     return $schedules; 
     250
     251/**
     252 * Add a 2 hourly schedule to cron
     253 *
     254 * @param $schedules
     255 *
     256 * @return mixed
     257 */
     258function cron_add_wprssmi_schedule_120( $schedules ) {
     259
     260    $period                = 7200;
     261    $schedules['twohours'] = array(
     262        'interval' => $period,
     263        'display'  => __( 'Once Every 2 Hours' )
     264    );
     265    return $schedules;
    179266}
    180267
    181268add_filter( 'cron_schedules', 'cron_add_wprssmi_schedule_120' );
    182269
    183 function cron_add_wprssmi_schedule_120( $schedules ) {  //add a 2 hourly schedule to cron
    184    
    185     $period=7200;
    186     $schedules['twohours'] = array(
    187         'interval' => $period,
    188         'display' => __( 'Once Every 2 Hours' )
    189     );
    190     return $schedules; 
    191 }
    192 
     270
     271/**
     272 * Aadd a 4 hourly schedule to cron
     273 *
     274 * @param $schedules
     275 *
     276 * @return mixed
     277 */
     278function cron_add_wprssmi_schedule_240( $schedules ) {
     279
     280    $period                 = 14400;
     281    $schedules['fourhours'] = array(
     282        'interval' => $period,
     283        'display'  => __( 'Once Every 4 Hours' )
     284    );
     285    return $schedules;
     286}
    193287
    194288add_filter( 'cron_schedules', 'cron_add_wprssmi_schedule_240' );
    195289
    196 function cron_add_wprssmi_schedule_240( $schedules ) {  //add a 4 hourly schedule to cron
    197    
    198     $period=14400;
    199     $schedules['fourhours'] = array(
    200         'interval' => $period,
    201         'display' => __( 'Once Every 4 Hours' )
    202     );
    203     return $schedules; 
    204 }
    205 
    206 
    207 
    208 
     290
     291/**
     292 * Call the find_db_transients function during the wp_rss_multi_event cron schedule
     293 */
    209294function wp_rss_multi_cron() {
    210295    find_db_transients();
    211296}
    212297
    213 
    214 function wp_rss_multi_delete_custom_posts(){
    215     rssmi_delete_custom_posts(); //  Delete feed items
    216 }
    217 
    218 
    219 function wp_rss_multi_cron_feedtopost() {  //Fetch AutoPost items from database
     298add_action( 'wp_rss_multi_event', 'wp_rss_multi_cron' );
     299
     300
     301/**
     302 * Find all WP RSS MI transients
     303 */
     304function find_db_transients() {
     305
     306    global $wpdb;
     307
     308    $expired = $wpdb->get_col( "
     309        SELECT option_name
     310        FROM {$wpdb->options}
     311        WHERE option_name
     312        LIKE '_transient_wprssmi_%';
     313    " );
     314
     315    if ( ! $expired ) {
     316        return;
     317    }
     318
     319    foreach ( $expired as $transient ) {
     320        $key = str_replace( '_transient_wprssmi_', '', $transient );
     321        wp_rss_multi_importer_shortcode( array( 'category' => $key ) );
     322    }
     323}
     324
     325
     326/**
     327 *  Delete feed items
     328 */
     329function wp_rss_multi_delete_custom_posts() {
     330    rssmi_delete_custom_posts();
     331}
     332
     333add_action( 'wp_rss_multi_event_delete_custom_posts', 'wp_rss_multi_delete_custom_posts' );
     334
     335
     336/**
     337 * Fetch AutoPost items from database
     338 */
     339function wp_rss_multi_cron_feedtopost() {
    220340    rssmi_import_feed_post();
    221341
     
    223343
    224344
    225 function wp_rss_multi_cron_importfeeds(){  //Import feed items
    226    
     345/**
     346 * Import feed items
     347 */
     348function wp_rss_multi_cron_importfeeds() {
    227349    rssmi_fetch_all_feed_items();
    228350
     
    230352
    231353
    232 function find_db_transients() {
    233 
    234     global $wpdb;
    235 
    236     $expired = $wpdb->get_col( "SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE '_transient_wprssmi_%';" );
    237     if ( $expired ) {
    238         foreach( $expired as $transient ) {
    239 
    240             $key = str_replace('_transient_wprssmi_', '', $transient);
    241             wp_rss_multi_importer_shortcode(array('category'=>$key));
    242 
    243         }
    244     }
    245 }
    246 
    247 
    248 register_deactivation_hook(__FILE__, 'wp_rss_multi_deactivation');
    249 
    250 function wp_rss_multi_deactivation($hook_event) {
    251     if ($hook_event==1){
    252     wp_clear_scheduled_hook('wp_rss_multi_event_feedtopost');
    253     }
    254 }
    255 
    256 
    257 ?>
     354
     355function wp_rss_multi_deactivation( $hook_event ) {
     356    if ( $hook_event == 1 ) {
     357        wp_clear_scheduled_hook( 'wp_rss_multi_event_feedtopost' );
     358    }
     359}
  • wp-rss-multi-importer/trunk/inc/custom_posts.php

    r976544 r989112  
    11<?php
    2  add_action( 'init', 'create_rssmi_feed' );
    3 
    4 function create_rssmi_feed()
    5 {
    6 
    7      
    8        $feed_args = array(
    9             'public'        => true,
    10             'query_var'     => 'feed_source',
    11             'menu_position' => 100,
    12             'exclude_from_search'   => true,
    13             'show_in_menu'  => false,
    14             'show_in_nav_menus' => false,
    15             'supports'      => array( 'title' ),
    16             'rewrite'       => array(
    17                                'slug'  => 'feeds',
    18                                'with_front' => false
    19                                ),           
    20             'labels'        => array(
    21                                'name'                  => __( 'Multi Importer - Feed List' ),
    22                                'singular_name'         => __( 'Feed' ),
    23                                'add_new'               => __( 'Add New Feed Source' ),
    24                                'all_items'             => __( 'View Feed Sources' ),
    25                                'add_new_item'          => __( 'Add New Feed Source' ),
    26                                'edit_item'             => __( 'Edit Feed Source' ),
    27                                'new_item'              => __( 'New Feed Source' ),
    28                                'view_item'             => __( 'View Feed Source' ),
    29                                'search_items'          => __( 'Search Feeds' ),
    30                                'not_found'             => __( 'No Feed Sources Found' ),
    31                                'not_found_in_trash'    => __( 'No Feed Sources Found In Trash' ),
    32                                'menu_name'             => __( 'RSS Multi Importer' )
    33                                ),
    34        );
    35        
    36  
    37        register_post_type( 'rssmi_feed', $feed_args );
    38 
    39    
    40        $feed_item_args = array(
    41            'public'         => true,
    42            'query_var'      => 'feed_item',
    43            'show_in_menu'   => false,
    44         'exclude_from_search'   => true,
    45             'show_in_nav_menus'  => false,
    46            'rewrite'        => array(
    47                                 'slug'  => 'feeds/items',
    48                                 'with_front' => false,
    49                                ),       
    50            'labels'         => array(
    51                                 'name'                  => __( 'Multi Importer Feed Items' ),
    52                                 'singular_name'         => __( 'Feed Items' ),
    53                                 'all_items'             => __( 'Feed Items' ),
    54                                 'view_item'             => __( 'View Feed Items' ),                           
    55                                 'search_items'          => __( 'Search Feed Items' ),
    56                                 'not_found'             => __( 'No Imported Feeds Found' ),
    57                                 'not_found_in_trash'    => __( 'No Imported Feeds Found In Trash')
    58                                ),
    59        );
    60        
    61        // Register the 'feed_item' post type
    62        register_post_type( 'rssmi_feed_item', $feed_item_args );       
    63 }
    64 
    65 add_action( 'admin_init', 'rssmi_my_admin' );
    66 
    67 function remove_publish_box()
    68 {
     2
     3/**
     4 * Create the 2 custom post types
     5 */
     6function create_rssmi_feed() {
     7
     8    // RSS Feeds
     9    $feed_args = array(
     10        'public'              => true,
     11        'query_var'           => 'feed_source',
     12        'exclude_from_search' => true,
     13        'show_in_menu'        => false,
     14        'show_in_nav_menus'   => false,
     15        'supports'            => array( 'title' ),
     16        'rewrite'             => array(
     17            'slug'       => 'feeds',
     18            'with_front' => false
     19        ),
     20        'labels'              => array(
     21            'name'               => __( 'Multi Importer - Feed List', 'wp-rss-multi-importer' ),
     22            'singular_name'      => __( 'Feed', 'wp-rss-multi-importer' ),
     23            'add_new'            => __( 'Add New Feed Source', 'wp-rss-multi-importer' ),
     24            'all_items'          => __( 'View Feed Sources', 'wp-rss-multi-importer' ),
     25            'add_new_item'       => __( 'Add New Feed Source', 'wp-rss-multi-importer' ),
     26            'edit_item'          => __( 'Edit Feed Source', 'wp-rss-multi-importer' ),
     27            'new_item'           => __( 'New Feed Source', 'wp-rss-multi-importer' ),
     28            'view_item'          => __( 'View Feed Source', 'wp-rss-multi-importer' ),
     29            'search_items'       => __( 'Search Feeds', 'wp-rss-multi-importer' ),
     30            'not_found'          => __( 'No Feed Sources Found', 'wp-rss-multi-importer' ),
     31            'not_found_in_trash' => __( 'No Feed Sources Found In Trash', 'wp-rss-multi-importer' ),
     32        ),
     33    );
     34
     35    register_post_type( 'rssmi_feed', $feed_args );
     36
     37    // RSS Feed Items
     38    // TODO: Disallow adding new with capabilities
     39    $feed_item_args = array(
     40        'public'              => true,
     41        'query_var'           => 'feed_item',
     42        'exclude_from_search' => true,
     43        'show_in_menu'        => false,
     44        'show_in_nav_menus'   => false,
     45        'rewrite'             => array(
     46            'slug'       => 'feeds/items',
     47            'with_front' => false,
     48        ),
     49        'labels'              => array(
     50            'name'               => __( 'Multi Importer Feed Items', 'wp-rss-multi-importer' ),
     51            'singular_name'      => __( 'Feed Items', 'wp-rss-multi-importer' ),
     52            'all_items'          => __( 'Feed Items', 'wp-rss-multi-importer' ),
     53            'view_item'          => __( 'View Feed Items', 'wp-rss-multi-importer' ),
     54            'search_items'       => __( 'Search Feed Items', 'wp-rss-multi-importer' ),
     55            'not_found'          => __( 'No Imported Feeds Found', 'wp-rss-multi-importer' ),
     56            'not_found_in_trash' => __( 'No Imported Feeds Found In Trash', 'wp-rss-multi-importer' )
     57        ),
     58    );
     59
     60    register_post_type( 'rssmi_feed_item', $feed_item_args );
     61}
     62
     63add_action( 'init', 'create_rssmi_feed' );
     64
     65
     66/**
     67 * Remove the publish box from RSS Feed edit page
     68 */
     69function rssmi_remove_publish_box() {
    6970    remove_meta_box( 'submitdiv', 'rssmi_feed', 'side' );
    70 
    71 
    72 }
    73 
    74 add_action( 'admin_menu', 'remove_publish_box' );
    75 
    76 
    77 
    78 
    79 
    80 
    81 add_filter( 'manage_edit-rssmi_feed_columns', 'rssmi_set_custom_columns');
    82    /*     
    83     Set up the custom columns for the list
    84 
    85     */     
    86    function rssmi_set_custom_columns( $columns ) {
    87 
    88        $columns = array (
    89         'cb'          => '<input type="checkbox" />',
    90         'title'       => __( 'Name', 'rssmi' ),
    91         'url'         => __( 'URL', 'rssmi' ),
    92         'category' => __( 'Category', 'rssmi' ),
    93         'bloguser' => __( 'User', 'rssmi' ),
    94         'feeditems' => __( 'Feed Items in DB', 'rssmi' ),
    95         'lastupdate'=> __('Last DB Update on','rssmi'),
    96         'ID' => __( 'ID', 'rssmi' ),
    97        );
    98        return $columns;
    99    }
    100 
    101 
    102 add_action('admin_head', 'rssmi_feed_column_width');
    103 
     71}
     72
     73add_action( 'admin_menu', 'rssmi_remove_publish_box' );
     74
     75
     76/**
     77 * Display custom columns for RSS Feeds
     78 *
     79 * @param $columns
     80 *
     81 * @return array
     82 */
     83function rssmi_set_custom_columns( $columns ) {
     84
     85    $columns = array(
     86        'cb'         => '<input type="checkbox" />',
     87        'title'      => __( 'Name', 'rssmi' ),
     88        'url'        => __( 'URL', 'rssmi' ),
     89        'category'   => __( 'Category', 'rssmi' ),
     90        'bloguser'   => __( 'User', 'rssmi' ),
     91        'feeditems'  => __( 'Feed Items in DB', 'rssmi' ),
     92        'lastupdate' => __( 'Last DB Update on', 'rssmi' ),
     93        'ID'         => __( 'ID', 'rssmi' ),
     94    );
     95    return $columns;
     96}
     97
     98add_filter( 'manage_edit-rssmi_feed_columns', 'rssmi_set_custom_columns' );
     99
     100
     101/**
     102 * Display custom columns for RSS Feeds
     103 *
     104 * @param $column
     105 * @param $post_id
     106 */
     107function rssmi_show_custom_columns( $column, $post_id ) {
     108    global $wpdb;
     109    switch ( $column ) {
     110        case 'url':
     111            $url = get_post_meta( $post_id, 'rssmi_url', true );
     112            echo '<a href="' . esc_url( $url ) . '">' . esc_url( $url ) . '</a>';
     113            break;
     114        case 'category':
     115            $category = get_post_meta( $post_id, 'rssmi_cat', true );
     116            echo esc_html( wp_getCategoryName( $category ) );
     117            break;
     118        case 'bloguser':
     119            $bloguser = get_post_meta( $post_id, 'rssmi_user', true );
     120            $bloguser = (int) $bloguser;
     121            echo esc_html( get_userdata( $bloguser )->display_name );
     122            break;
     123        case 'feeditems':
     124            $post_count = $wpdb->get_var( $wpdb->prepare( "SELECT count(*) FROM (SELECT * from $wpdb->postmeta as a inner join $wpdb->posts as b on b.id=a.post_id where meta_key='rssmi_item_feed_id' and meta_value=%d order by post_id desc LIMIT 25) as c order by post_id ASC", $post_id ) );
     125            echo $post_count;
     126            break;
     127        case 'lastupdate':
     128            if ( get_post_meta( $post_id, 'rssmi_last_update', true ) != '' ) {
     129                $last_update = get_post_meta( $post_id, 'rssmi_last_update', true );
     130                echo get_date_from_gmt( date( 'Y-m-d H:i:s', $last_update ), 'M j, Y @ g:i a  ' );
     131            }
     132            else {
     133                echo "No Recent Update Yet";
     134            }
     135            break;
     136
     137        case 'ID':
     138            echo $post_id;
     139            break;
     140    }
     141}
     142
     143add_action( "manage_rssmi_feed_posts_custom_column", "rssmi_show_custom_columns", 10, 2 );
     144
     145
     146/**
     147 * Set custom CSS for feed columns
     148 * TODO: CSS should be more specific and included in the main CSS sheet
     149 */
    104150function rssmi_feed_column_width() {
    105     echo '<style type="text/css">';
    106     echo '.column-title {width:280px !important;  }';
    107     echo '.column-url {width:280px !important;  }';
     151    echo '<style type="text/css">';
     152    echo '.column-title {width:280px !important;  }';
     153    echo '.column-url {width:280px !important;  }';
    108154    echo '.column-bloguser {width:120px !important;  }';
    109155//  echo 'th.column-feeditems {font-size:12px !important;  }';
    110156    echo '.column-feeditems {text-align:center !important;  }';
    111     echo '</style>';
    112 }
    113 
    114 
    115     add_action( "manage_rssmi_feed_posts_custom_column", "rssmi_show_custom_columns", 10, 2 );
    116    /*
    117     Show up the custom columns for the  list
    118 
    119     */ 
    120    function rssmi_show_custom_columns( $column, $post_id ) {
    121         global $wpdb;
    122      switch ( $column ) {   
    123        case 'url':
    124             $url = get_post_meta( $post_id, 'rssmi_url', true);
    125             echo '<a href="' . esc_url($url) . '">' . esc_url($url) . '</a>';
    126             break;
    127        case 'category':
    128             $category = get_post_meta( $post_id, 'rssmi_cat', true);
    129             echo esc_html( wp_getCategoryName($category) );
    130             break; 
    131         case 'bloguser':
    132             $bloguser = get_post_meta( $post_id, 'rssmi_user', true);
    133             $bloguser=(int) $bloguser;
    134             echo esc_html(get_userdata($bloguser)->display_name );
    135             break;
    136         case 'feeditems':
    137             $post_count = $wpdb->get_var($wpdb->prepare("SELECT count(*) FROM (SELECT * from $wpdb->postmeta as a inner join $wpdb->posts as b on b.id=a.post_id where meta_key='rssmi_item_feed_id' and meta_value=%d order by post_id desc LIMIT 25) as c order by post_id ASC",$post_id));
    138             echo $post_count;
    139             break;
    140         case 'lastupdate':
    141             if(get_post_meta( $post_id, 'rssmi_last_update', true) !=''){
    142                 $last_update=get_post_meta( $post_id, 'rssmi_last_update', true) ;
    143                 echo get_date_from_gmt(date('Y-m-d H:i:s',$last_update),'M j, Y @ g:i a  ');
    144             }else{
    145                 echo "No Recent Update Yet";
    146             }
    147             break; 
    148            
    149         case 'ID':
    150             echo $post_id;
    151             break;   
    152      }
    153    }
    154 add_filter('manage_edit-rssmi_feed_sortable_columns', 'rssmi_sortable_columns');
    155 
    156    /*
    157     * Make the custom columns sortable
    158     */ 
    159    function rssmi_sortable_columns() {
    160        return array(
    161            // meta column id => sortby value used in query
    162            'title' => 'title',   
    163           'category' => 'category'
    164        );
    165    }
    166 
    167 
    168    add_filter( 'manage_edit-rssmi_feed_item_columns', 'rssmi_set_feed_item_custom_columns');
    169    /*
    170     Set up the custom columns for the  source list
    171 
    172     */     
    173    function rssmi_set_feed_item_custom_columns( $columns ) {
    174  //rssmi_fetch_all_feed_items();
    175        $columns = array (
    176            'cb'          => '<input type="checkbox" />',
    177            'title'        => __( 'Name', 'rssmi' ),
    178            'permalink'   => __( 'Permalink', 'rssmi' ),
    179            'publishdate' => __( 'Date published', 'rssmi' ),
    180            'source'      => __( 'Source', 'rssmi' )
    181        );
    182        return $columns;
    183    }
    184 
    185 
    186 
    187 
    188     add_action( "manage_rssmi_feed_item_posts_custom_column", "rssmi_show_feed_item_custom_columns", 10, 2 );
    189    /*
    190     Show up the custom columns for the feed list
    191     */ 
    192    function rssmi_show_feed_item_custom_columns( $column, $post_id ) {
    193 
    194        switch ( $column ) {             
    195            case "permalink":
    196                $url = get_post_meta( $post_id, 'rssmi_item_permalink', true);
    197                echo '<a href="' . $url . '">' . $url. '</a>';
    198                break;         
    199            
    200            case "publishdate":
    201 
    202               $publishdate = get_date_from_gmt(date( 'Y-m-d H:i:s', intval(get_post_meta( get_the_ID(), 'rssmi_item_date', true ) )) );   
    203         //  $publishdate = date( 'Y/m/d', intval(get_post_meta( get_the_ID(), 'rssmi_item_date', true ) )) ;         
    204                echo $publishdate;
    205                break;   
    206            
    207            case "source":       
    208                //$query = new WP_Query();   
    209             $source =  get_the_title(get_post_meta( $post_id, 'rssmi_item_feed_id', true )) ;
    210          
    211               // $source = '<a href="' . get_edit_post_link( get_post_meta( $post_id, 'rssmi_feed_id', true ) ) . '">' . get_the_title( get_post_meta( $post_id, 'rssmi_feed_id', true ) ) . '</a>';               
    212                echo $source;
    213                break;   
    214        }
    215    }
    216 
    217 
    218 
    219 add_filter('manage_edit-rssmi_feed_item_sortable_columns', 'rssmi_sortable_item_columns');
    220 
    221    /*
    222     * Make the custom columns sortable
    223     */ 
    224    function rssmi_sortable_item_columns() {
    225        return array(
    226            // meta column id => sortby value used in query
    227            'source' => 'source',   
    228          
    229        );
    230    }
    231 
    232 
    233 
    234 
    235 
    236 
    237 
    238 
    239 
    240 
    241 
    242 
    243     add_action( 'add_meta_boxes', 'rssmi_add_meta_boxes');
    244    /*
    245     Set up the input boxes for the rssmi_feed post type
    246     */   
    247    function rssmi_add_meta_boxes() {
    248        global $rssmi_meta_fields;
    249         $content_image=WP_RSS_MULTI_IMAGES."content_image.png";
    250         $media_image=WP_RSS_MULTI_IMAGES."media_image.png";
    251 
    252        // Remove the default WordPress Publish box, because we will be using custom ones
    253     remove_meta_box( 'submitdiv', 'rssmi_feed', 'side' );
    254     add_meta_box(
    255            'rssmi-save-link-side-meta',
    256            'Save Feed Source',
    257            'rssmi_save_feed_source_meta_box',
    258            'rssmi_feed',
    259            'side',
    260            'high'
    261        );
    262 
    263        
    264        add_meta_box(
    265            'custom_meta_box', // $id
    266            __( 'Feed Source Details', 'rssmi' ), // $title
    267            'display_rssmi_feed_meta_box', // $callback
    268            'rssmi_feed', // $page
    269            'normal', // $context
    270            'high'); // $priority
    271 
    272 
    273         add_meta_box(
    274                'note_meta_box', // $id
    275                __( 'Important Note', 'rssmi' ), // $title
    276                'rssmi_save_feed_note_meta_box', // $callback
    277                'rssmi_feed', // $page
    278                'side', // $context
    279                'low'); // $priority
    280    
    281                 add_meta_box(
    282                        'images_explain_meta_box', // $id
    283                        __( 'What do <img src='.$content_image.'> & <img src='.$media_image.'> mean?', 'rssmi' ), // $title
    284                        'rssmi_images_explain_meta_box', // $callback
    285                        'rssmi_feed', // $page
    286                        'side', // $context
    287                        'low'); // $priority
    288    
    289    
    290             add_meta_box(
    291                    'can_do_meta_box', // $id
    292                    __( 'DO MORE WITH YOUR FEED', 'rssmi' ), // $title
    293                    'rssmi_feed_can_do_notes', // $callback
    294                    'rssmi_feed', // $page
    295                    'side', // $context
    296                    'low'); // $priority
    297 
    298 
    299        add_meta_box(
    300            'preview_meta_box', // $id
    301            __( 'Feed Preview ', 'rssmi' ), // $title
    302            'rssmi_preview_meta_box', // $callback
    303            'rssmi_feed', // $page
    304            'normal', // $context
    305            'low'); // $priority
    306 
    307 
    308    
    309        
    310 
    311         //  This adds the box with a direct link to the Add Multiple Feeds option
    312             add_meta_box(
    313                    'rssmi-add-multiple',
    314                    'Delete and Fetch the Items for this Feed Now',
    315                    'rssmi_delete_posts_for_feed',
    316                    'rssmi_feed',
    317                    'normal',
    318                    'low'
    319                );
    320        
    321             add_meta_box(
    322                    'rssmi-add-multiple2',
    323                    'Most Recent Items in the Database',
    324                    'rssmi_most_current_posts_meta_box',
    325                    'rssmi_feed',
    326                    'normal',
    327                    'low'
    328                );
    329        
    330        
    331        
    332        
    333        
    334    }   
    335 
    336 
    337 
    338  
    339 
    340 
    341 
    342         function rssmi_save_feed_source_meta_box() {
    343                 global $post;
    344 
    345                 $post_status = ($post->post_status=="auto-draft")?"publish":$post->post_status;
    346 
    347                /**
    348                  * Check if user has disabled trash, in that case he can only delete feed sources permanently,
    349                  * else he can deactivate them. By default, if not modified in wp_config.php, EMPTY_TRASH_DAYS is set to 30.
    350                  */
    351                 if ( current_user_can( "delete_post", $post->ID ) ) {
    352                     if ( ! EMPTY_TRASH_DAYS )
    353                     {
    354                         $delete_text = __('Delete Permanently');
    355                     }
    356                     else
    357                     {
    358                         $delete_text = __('Move Feed to Trash');
    359                     }
    360                     echo ' 
     157    echo '</style>';
     158}
     159
     160add_action( 'admin_head', 'rssmi_feed_column_width' );
     161
     162
     163/**
     164 * Make the custom columns sortable
     165 *
     166 * @return array
     167 */
     168function rssmi_sortable_columns() {
     169    return array(
     170        // meta column id => sortby value used in query
     171        'title'    => 'title',
     172        'category' => 'category'
     173    );
     174}
     175
     176add_filter( 'manage_edit-rssmi_feed_sortable_columns', 'rssmi_sortable_columns' );
     177
     178
     179add_filter( 'manage_edit-rssmi_feed_item_columns', 'rssmi_set_feed_item_custom_columns' );
     180/*
     181    Set up the custom columns for the  source list
     182
     183    */
     184function rssmi_set_feed_item_custom_columns( $columns ) {
     185    //rssmi_fetch_all_feed_items();
     186    $columns = array(
     187        'cb'          => '<input type="checkbox" />',
     188        'title'       => __( 'Name', 'rssmi' ),
     189        'permalink'   => __( 'Permalink', 'rssmi' ),
     190        'publishdate' => __( 'Date published', 'rssmi' ),
     191        'source'      => __( 'Source', 'rssmi' )
     192    );
     193    return $columns;
     194}
     195
     196
     197add_action( "manage_rssmi_feed_item_posts_custom_column", "rssmi_show_feed_item_custom_columns", 10, 2 );
     198/*
     199    Show up the custom columns for the feed list
     200    */
     201function rssmi_show_feed_item_custom_columns( $column, $post_id ) {
     202
     203    switch ( $column ) {
     204        case "permalink":
     205            $url = get_post_meta( $post_id, 'rssmi_item_permalink', true );
     206            echo '<a href="' . $url . '">' . $url . '</a>';
     207            break;
     208
     209        case "publishdate":
     210
     211            $publishdate = get_date_from_gmt( date( 'Y-m-d H:i:s', intval( get_post_meta( get_the_ID(), 'rssmi_item_date', true ) ) ) );
     212            //  $publishdate = date( 'Y/m/d', intval(get_post_meta( get_the_ID(), 'rssmi_item_date', true ) )) ;
     213            echo $publishdate;
     214            break;
     215
     216        case "source":
     217            //$query = new WP_Query();
     218            $source = get_the_title( get_post_meta( $post_id, 'rssmi_item_feed_id', true ) );
     219
     220            // $source = '<a href="' . get_edit_post_link( get_post_meta( $post_id, 'rssmi_feed_id', true ) ) . '">' . get_the_title( get_post_meta( $post_id, 'rssmi_feed_id', true ) ) . '</a>';
     221            echo $source;
     222            break;
     223    }
     224}
     225
     226
     227add_filter( 'manage_edit-rssmi_feed_item_sortable_columns', 'rssmi_sortable_item_columns' );
     228
     229/*
     230    * Make the custom columns sortable
     231    */
     232function rssmi_sortable_item_columns() {
     233    return array(
     234        // meta column id => sortby value used in query
     235        'source' => 'source',
     236
     237    );
     238}
     239
     240
     241add_action( 'add_meta_boxes', 'rssmi_add_meta_boxes' );
     242/*
     243    Set up the input boxes for the rssmi_feed post type
     244    */
     245function rssmi_add_meta_boxes() {
     246    global $rssmi_meta_fields;
     247    $content_image = WP_RSS_MULTI_IMAGES . "content_image.png";
     248    $media_image   = WP_RSS_MULTI_IMAGES . "media_image.png";
     249
     250    // Remove the default WordPress Publish box, because we will be using custom ones
     251    remove_meta_box( 'submitdiv', 'rssmi_feed', 'side' );
     252    add_meta_box(
     253        'rssmi-save-link-side-meta',
     254        'Save Feed Source',
     255        'rssmi_save_feed_source_meta_box',
     256        'rssmi_feed',
     257        'side',
     258        'high'
     259    );
     260
     261
     262    add_meta_box(
     263        'custom_meta_box', // $id
     264        __( 'Feed Source Details', 'rssmi' ), // $title
     265        'display_rssmi_feed_meta_box', // $callback
     266        'rssmi_feed', // $page
     267        'normal', // $context
     268        'high' ); // $priority
     269
     270
     271    add_meta_box(
     272        'note_meta_box', // $id
     273        __( 'Important Note', 'rssmi' ), // $title
     274        'rssmi_save_feed_note_meta_box', // $callback
     275        'rssmi_feed', // $page
     276        'side', // $context
     277        'low' ); // $priority
     278
     279    add_meta_box(
     280        'images_explain_meta_box', // $id
     281        __( 'What do <img src=' . $content_image . '> & <img src=' . $media_image . '> mean?', 'rssmi' ), // $title
     282        'rssmi_images_explain_meta_box', // $callback
     283        'rssmi_feed', // $page
     284        'side', // $context
     285        'low' ); // $priority
     286
     287
     288    add_meta_box(
     289        'can_do_meta_box', // $id
     290        __( 'DO MORE WITH YOUR FEED', 'rssmi' ), // $title
     291        'rssmi_feed_can_do_notes', // $callback
     292        'rssmi_feed', // $page
     293        'side', // $context
     294        'low' ); // $priority
     295
     296
     297    add_meta_box(
     298        'preview_meta_box', // $id
     299        __( 'Feed Preview ', 'rssmi' ), // $title
     300        'rssmi_preview_meta_box', // $callback
     301        'rssmi_feed', // $page
     302        'normal', // $context
     303        'low' ); // $priority
     304
     305
     306    //  This adds the box with a direct link to the Add Multiple Feeds option
     307    add_meta_box(
     308        'rssmi-add-multiple',
     309        'Delete and Fetch the Items for this Feed Now',
     310        'rssmi_delete_posts_for_feed',
     311        'rssmi_feed',
     312        'normal',
     313        'low'
     314    );
     315
     316    add_meta_box(
     317        'rssmi-add-multiple2',
     318        'Most Recent Items in the Database',
     319        'rssmi_most_current_posts_meta_box',
     320        'rssmi_feed',
     321        'normal',
     322        'low'
     323    );
     324
     325
     326}
     327
     328
     329function rssmi_save_feed_source_meta_box() {
     330    global $post;
     331
     332    $post_status = ( $post->post_status == "auto-draft" ) ? "publish" : $post->post_status;
     333
     334    /**
     335     * Check if user has disabled trash, in that case he can only delete feed sources permanently,
     336     * else he can deactivate them. By default, if not modified in wp_config.php, EMPTY_TRASH_DAYS is set to 30.
     337     */
     338    if ( current_user_can( "delete_post", $post->ID ) ) {
     339        if ( ! EMPTY_TRASH_DAYS ) {
     340            $delete_text = __( 'Delete Permanently' );
     341        }
     342        else {
     343            $delete_text = __( 'Move Feed to Trash' );
     344        }
     345        echo '
    361346                        <div class="submitbox" id="submitpost" >
    362347                            <div id="major-publishing-actions">
    363348                                <div id="publishing-action" style="float:left" >
    364349                                    <span class="spinner"></span>
    365         <input type="hidden" name="post_status" id="post_status" value="'.$post_status.'" />
     350        <input type="hidden" name="post_status" id="post_status" value="' . $post_status . '" />
    366351                                    <input name="original_publish" type="hidden" id="original_publish" value="Update" />
    367352                                    <input name="save" type="submit" class="button button-primary button-large" id="publish" accesskey="s" value="Save Feed" />
    368353                                </div>
    369354                                <div id="delete-action" style="float:right">
    370                                     <a class="submitdelete deletion" href="'.get_delete_post_link( $post->ID ).'">'.$delete_text.'</a>
     355                                    <a class="submitdelete deletion" href="' . get_delete_post_link( $post->ID ) . '">' . $delete_text . '</a>
    371356                                </div>
    372357                                <div class="clear"></div>
     358                                <p><strong>Please read the note below before deleting this feed.</strong></p>
    373359                            </div>
    374360                        </div>
    375361                        ';
    376                 }
    377             }
    378 
    379 
    380 
    381 
    382 
    383 
    384     function rssmi_save_feed_note_meta_box() {
    385             global $post;
    386             if ( current_user_can( "delete_post", $post->ID ) ) {
    387 
    388     if ( EMPTY_TRASH_DAYS ){
    389     echo '<strong>Important:</strong> If you move a feed to trash, you must make sure it is deleted permanently before the items associated with that feed will be deleted.  Go to the Feed List, check for feeds in trash and delete permanently.';
    390     }
    391             }
    392         }
    393 
    394 function rssmi_images_explain_meta_box(){
    395     $content_image=WP_RSS_MULTI_IMAGES."content_image.png";
    396     $media_image=WP_RSS_MULTI_IMAGES."media_image.png";
    397 echo '<img src='.$content_image.'> image exists in the content<br> <img src='.$media_image.'> image exists in the media enclosure';
    398 echo '<p>If no icons show up next to the titles, it\'s likely there are no images in this feed.</p>';
    399 }
    400 
    401 
    402 function rssmi_add_multiple_feeds_meta_box(){
    403    
    404     _e("<a href=\"admin.php?page=wprssmi_options8\">Click here to add a bunch of feeds.</a>", 'wp-rss-multi-importer');
    405 }
    406 
    407 
    408 function rssmi_feed_can_do_notes(){
    409    
    410         _e("<p>You can filter your feed by keywords, add a category image and more. First, put your feed into a category then <a href=\"admin.php?page=wprssmi_options\">go here to add keywords.</a></p><p>Learn how the keyword filtering works by <a href='http://www.wprssimporter.com/faqs/how-do-the-filters-work/' target='_blank'>going here</a>.", 'wp-rss-multi-importer');
    411 }
    412 
    413 
    414 
     362    }
     363}
     364
     365
     366function rssmi_save_feed_note_meta_box() {
     367    global $post;
     368    if ( current_user_can( "delete_post", $post->ID ) ) {
     369
     370        echo '<strong>Important:</strong> Deleting a feed will also delete all of the associated feed items and auto-posts as well. If you move a feed to trash, these will remain until the feed is deleted permanently. To delete the feed and all items immediately, go to <strong>Multi Importer > Feed List</strong>, click the Trash link near the top, then click the <strong>Empty Trash</strong> button.';
     371    }
     372}
     373
     374function rssmi_images_explain_meta_box() {
     375    $content_image = WP_RSS_MULTI_IMAGES . "content_image.png";
     376    $media_image   = WP_RSS_MULTI_IMAGES . "media_image.png";
     377    echo '<img src=' . $content_image . '> image exists in the content<br> <img src=' . $media_image . '> image exists in the media enclosure';
     378    echo '<p>If no icons show up next to the titles, it\'s likely there are no images in this feed.</p>';
     379}
     380
     381
     382function rssmi_add_multiple_feeds_meta_box() {
     383
     384    _e( "<a href=\"admin.php?page=wprssmi_options8\">Click here to add a bunch of feeds.</a>", 'wp-rss-multi-importer' );
     385}
     386
     387
     388function rssmi_feed_can_do_notes() {
     389
     390    _e( "<p>You can filter your feed by keywords, add a category image and more. First, put your feed into a category then <a href=\"admin.php?page=wprssmi_options\">go here to add keywords.</a></p><p>Learn how the keyword filtering works by <a href='http://www.wprssimporter.com/faqs/how-do-the-filters-work/' target='_blank'>going here</a>.", 'wp-rss-multi-importer' );
     391}
    415392
    416393
    417394// Hide "add new" button on edit page
    418395function hd_add_buttons() {
    419   global $pagenow;
    420 
    421   if(is_admin()){
    422     if($pagenow == 'edit.php' && $_GET['post_type'] == 'rssmi_feed_item'){
    423     echo '<style>.add-new-h2{display: none;}</style>';
    424     }
    425   }
    426 }
    427 add_action('admin_head','hd_add_buttons');
     396    global $pagenow;
     397
     398    if ( is_admin() ) {
     399        if ( $pagenow == 'edit.php' && isset( $_GET['post_type'] ) && $_GET['post_type'] == 'rssmi_feed_item' ) {
     400            echo '<style>.add-new-h2{display: none;}</style>';
     401        }
     402    }
     403}
     404
     405add_action( 'admin_head', 'hd_add_buttons' );
    428406
    429407
    430408// Highlight plugin admin menu when on edit screen
    431 function highlight_rssmi_menu(){
     409function highlight_rssmi_menu() {
    432410    $screen = get_current_screen();
    433411    global $pagenow;
    434412    global $parent_file;
    435     if($pagenow == 'post.php' && 'rssmi_feed' == $screen->post_type ){
     413    if ( $pagenow == 'post.php' && 'rssmi_feed' == $screen->post_type ) {
    436414        global $parent_file;
    437415        $parent_file = 'wprssmi';
    438416        echo '<style>#edit-slug-box{display: none;}</style>';
    439        
    440     }
    441 }
    442 add_action('admin_head','highlight_rssmi_menu');
    443 
    444 
     417
     418    }
     419}
     420
     421add_action( 'admin_head', 'highlight_rssmi_menu' );
    445422
    446423
    447424//  give message that feed has been saved (instead of default post message)
    448 add_filter('post_updated_messages', 'rssmi_updated_messages');
     425add_filter( 'post_updated_messages', 'rssmi_updated_messages' );
    449426function rssmi_updated_messages( $messages ) {
    450427    global $pagenow;
    451428    $screen = get_current_screen();
    452         if($pagenow == 'post.php' && 'rssmi_feed' == $screen->post_type ){
    453             $messages["post"][6] = 'The feed has been successfully saved.';
    454         }
    455 return $messages;
    456 }
    457 
    458 
    459 function change_default_title( $title ){
    460      $screen = get_current_screen();
    461  
    462      if ( 'rssmi_feed' == $screen->post_type ) {
    463           $title = 'Name your feed here - e.g., the source of the RSS feed';
    464      }
    465      return $title;
    466 }
    467  
     429    if ( $pagenow == 'post.php' && 'rssmi_feed' == $screen->post_type ) {
     430        $messages["post"][6] = 'The feed has been successfully saved.';
     431    }
     432    return $messages;
     433}
     434
     435
     436function change_default_title( $title ) {
     437    $screen = get_current_screen();
     438
     439    if ( 'rssmi_feed' == $screen->post_type ) {
     440        $title = 'Name your feed here - e.g., the source of the RSS feed';
     441    }
     442    return $title;
     443}
     444
    468445add_filter( 'enter_title_here', 'change_default_title' );
    469446
    470447
    471 
    472 
    473 
    474 add_filter('post_row_actions', 'rssmi_delete_view_link', 10, 2);
    475 
    476 function rssmi_delete_view_link($actions, $page_object)
    477 {
     448add_filter( 'post_row_actions', 'rssmi_delete_view_link', 10, 2 );
     449
     450function rssmi_delete_view_link( $actions, $page_object ) {
    478451    $screen = get_current_screen();
    479    
    480     if  ( 'rssmi_feed_item' == $screen->post_type ) {
     452
     453    if ( 'rssmi_feed_item' == $screen->post_type ) {
    481454        unset( $actions['view'] );
    482455        unset( $actions['edit'] );
    483         unset( $actions['inline hide-if-no-js'] );  //  remove quick edit
    484 }
    485    return $actions;
    486 }
    487 
    488 
    489 
    490 add_filter('post_row_actions', 'rssmi_feed_list_view_link', 10, 2);  //  NEEDS WORK
    491 
    492 function rssmi_feed_list_view_link($actions, $post)
    493 {
    494     $screen = get_current_screen();
    495     $dismiss_link_joiner = ( count($_GET) > 0 ) ? '&amp;':'?';
    496     if  ( 'rssmi_feed' == $screen->post_type ) {
    497             unset( $actions['view'] );
    498         unset( $actions['inline hide-if-no-js'] );  //  remove quick edit
    499     //  $actions['rssmi_fetch_items'] = '<a  href="javascript:;" pid="'.$post->ID.'" class="rssmi-fetch-items-now" >' . __('Delete Items') . '</a>';
    500     $actions['rssmi_delete_items'] = '<a  href="'.$_SERVER['REQUEST_URI'].$dismiss_link_joiner.'rssmi_delete_items='.$post->ID.'" class="rssmi-fetch-items-now" >' . __('Delete Items') . '</a>';
    501     $actions['rssmi_view_items'] = '<a  href="'.admin_url().'edit.php?post_type=rssmi_feed_item&rssmi_feed_id='.$post->ID.'" >' . __('View Items') . '</a>';
    502 }
    503    return $actions;
     456        unset( $actions['inline hide-if-no-js'] ); //  remove quick edit
     457    }
     458    return $actions;
     459}
     460
     461
     462add_filter( 'post_row_actions', 'rssmi_feed_list_view_link', 10, 2 ); //  NEEDS WORK
     463
     464function rssmi_feed_list_view_link( $actions, $post ) {
     465    $screen              = get_current_screen();
     466    $dismiss_link_joiner = ( count( $_GET ) > 0 ) ? '&amp;' : '?';
     467    if ( 'rssmi_feed' == $screen->post_type ) {
     468        unset( $actions['view'] );
     469        unset( $actions['inline hide-if-no-js'] ); //  remove quick edit
     470        //  $actions['rssmi_fetch_items'] = '<a  href="javascript:;" pid="'.$post->ID.'" class="rssmi-fetch-items-now" >' . __('Delete Items') . '</a>';
     471        $actions['rssmi_delete_items'] = '<a  href="' . $_SERVER['REQUEST_URI'] . $dismiss_link_joiner . 'rssmi_delete_items=' . $post->ID . '" class="rssmi-fetch-items-now" >' . __( 'Delete Items' ) . '</a>';
     472        $actions['rssmi_view_items']   = '<a  href="' . admin_url() . 'edit.php?post_type=rssmi_feed_item&rssmi_feed_id=' . $post->ID . '" >' . __( 'View Items' ) . '</a>';
     473    }
     474    return $actions;
    504475}
    505476
    506477
    507478add_action( 'admin_init', 'rssmi_check_delete_items' );
    508 function rssmi_check_delete_items(){
    509     if( isset($_GET['rssmi_delete_items']) && !empty($_GET['rssmi_delete_items']) ){
     479function rssmi_check_delete_items() {
     480    if ( isset( $_GET['rssmi_delete_items'] ) && ! empty( $_GET['rssmi_delete_items'] ) ) {
    510481        $feed_id = $_GET['rssmi_delete_items'];
    511         rssmi_on_delete($feed_id);
    512         $page = isset( $_GET['paged'] )? '&paged=' . $_GET['paged'] : '';
    513         header( 'Location: ' . admin_url( 'edit.php?post_type=rssmi_feed' . $page ) );
    514         exit();
    515     }
    516        
    517 }
    518 
    519 
    520 
    521     /**     
    522     * Set up the meta box for the wprss_feed post type
    523     *
    524     * @since 2.0
    525     */
    526    function rssmi_show_meta_box() {
    527        global $post;
    528  
    529        // Use nonce for verification
    530        echo '<input type="hidden" name="rssmi_meta_box_nonce" value="' . wp_create_nonce( basename( __FILE__ ) ) . '" />';
    531            
    532            // Begin the field table and loop
    533            echo '<table class="form-table">';
    534            foreach ( $meta_fields as $field ) {
    535                // get value of this field if it exists for this post
    536                $meta = get_post_meta( $post->ID, $field['id'], true );
    537                // begin a table row with
    538                echo '<tr>
     482        rssmi_on_delete( $feed_id );
     483        $page = isset( $_GET['paged'] ) ? '&paged=' . $_GET['paged'] : '';
     484        header( 'Location: ' . admin_url( 'edit.php?post_type=rssmi_feed' . $page ) );
     485        exit();
     486    }
     487
     488}
     489
     490
     491/**
     492 * Set up the meta box for the wprss_feed post type
     493 *
     494 * @since 2.0
     495 */
     496function rssmi_show_meta_box() {
     497    global $post;
     498
     499    // Use nonce for verification
     500    echo '<input type="hidden" name="rssmi_meta_box_nonce" value="' . wp_create_nonce( basename( __FILE__ ) ) . '" />';
     501
     502    // Begin the field table and loop
     503    echo '<table class="form-table">';
     504    foreach ( $meta_fields as $field ) {
     505        // get value of this field if it exists for this post
     506        $meta = get_post_meta( $post->ID, $field['id'], true );
     507        // begin a table row with
     508        echo '<tr>
    539509                       <th><label for="' . $field['id'] . '">' . $field['label'] . '</label></th>
    540510                       <td>';
    541                        
    542                        switch( $field['type'] ) {
    543                        
    544                            // text
    545                            case 'text':
    546                                echo '<input type="text" name="'.$field['id'].'" id="'.$field['id'].'" value="'.$meta.'" size="55" />
    547                                    <br /><span class="description">'.$field['desc'].'</span>';
    548                            break;
    549                        
    550                            // textarea
    551                            case 'textarea':
    552                                echo '<textarea name="'.$field['id'].'" id="'.$field['id'].'" cols="60" rows="4">'.$meta.'</textarea>
    553                                    <br /><span class="description">'.$field['desc'].'</span>';
    554                            break;
    555                        
    556                            // checkbox
    557                            case 'checkbox':
    558                                echo '<input type="checkbox" name="'.$field['id'].'" id="'.$field['id'].'" ',$meta ? ' checked="checked"' : '','/>
    559                                    <label for="'.$field['id'].'">'.$field['desc'].'</label>';
    560                            break;   
    561                        
    562                            // select
    563                            case 'select':
    564                                echo '<select name="'.$field['id'].'" id="'.$field['id'].'">';
    565                                foreach ($field['options'] as $option) {
    566                                    echo '<option', $meta == $option['value'] ? ' selected="selected"' : '', ' value="'.$option['value'].'">'.$option['label'].'</option>';
    567                                }
    568                                echo '</select><br /><span class="description">'.$field['desc'].'</span>';
    569                            break;                                           
    570                        
    571                        } //end switch
    572                echo '</td></tr>';
    573            } // end foreach
    574            echo '</table>'; // end table
    575    }
    576 
    577 
    578 function rssmi_most_current_posts_meta_box( $post ){
     511
     512        switch ( $field['type'] ) {
     513
     514            // text
     515            case 'text':
     516                echo '<input type="text" name="' . $field['id'] . '" id="' . $field['id'] . '" value="' . $meta . '" size="55" />
     517                                   <br /><span class="description">' . $field['desc'] . '</span>';
     518                break;
     519
     520            // textarea
     521            case 'textarea':
     522                echo '<textarea name="' . $field['id'] . '" id="' . $field['id'] . '" cols="60" rows="4">' . $meta . '</textarea>
     523                                   <br /><span class="description">' . $field['desc'] . '</span>';
     524                break;
     525
     526            // checkbox
     527            case 'checkbox':
     528                echo '<input type="checkbox" name="' . $field['id'] . '" id="' . $field['id'] . '" ', $meta ? ' checked="checked"' : '', '/>
     529                                   <label for="' . $field['id'] . '">' . $field['desc'] . '</label>';
     530                break;
     531
     532            // select
     533            case 'select':
     534                echo '<select name="' . $field['id'] . '" id="' . $field['id'] . '">';
     535                foreach ( $field['options'] as $option ) {
     536                    echo '<option', $meta == $option['value'] ? ' selected="selected"' : '', ' value="' . $option['value'] . '">' . $option['label'] . '</option>';
     537                }
     538                echo '</select><br /><span class="description">' . $field['desc'] . '</span>';
     539                break;
     540
     541        } //end switch
     542        echo '</td></tr>';
     543    } // end foreach
     544    echo '</table>'; // end table
     545}
     546
     547
     548function rssmi_most_current_posts_meta_box( $post ) {
    579549    global $wpdb;
    580550
    581    
    582 $sql="SELECT * FROM (SELECT post_id, post_title from $wpdb->postmeta as a inner join $wpdb->posts as b on b.id=a.post_id where meta_key='rssmi_item_feed_id' and meta_value=".$post->ID." order by post_id desc LIMIT 10) as c order by post_id ASC";
    583 
    584     $current_post_array=$wpdb->get_results($sql);
    585 
    586     if (!empty($current_post_array)){
    587          echo '<h4>A few of the most recent feed items available for the Shortcode or to put in the AutoPost database from ' . get_the_title() . '</h4>';
     551
     552    $sql = "SELECT * FROM (SELECT post_id, post_title from $wpdb->postmeta as a inner join $wpdb->posts as b on b.id=a.post_id where meta_key='rssmi_item_feed_id' and meta_value=" . $post->ID . " order by post_id desc LIMIT 10) as c order by post_id ASC";
     553
     554    $current_post_array = $wpdb->get_results( $sql );
     555
     556    if ( ! empty( $current_post_array ) ) {
     557        echo '<h4>A few of the most recent feed items available for the Shortcode or to put in the AutoPost database from ' . get_the_title() . '</h4>';
    588558        echo '<ul>';
    589         foreach ($current_post_array as $a){
    590            
    591             echo '<li>'.$a->post_title.'</li>';
    592         }       
     559        foreach ( $current_post_array as $a ) {
     560
     561            echo '<li>' . $a->post_title . '</li>';
     562        }
    593563        echo '</ul>';
    594         echo "There are ".$wpdb->num_rows." total items in the database."; 
    595     }else{
     564        echo "There are " . $wpdb->num_rows . " total items in the database.";
     565    }
     566    else {
    596567        echo 'There are no feed items in the database. Click Fetch Now.';
    597568    }
     
    599570
    600571
    601 
    602 
    603572function rssmi_preview_meta_box() {
    604         global $post;
    605         $feed_url = get_post_meta( $post->ID, 'rssmi_url', true );
    606         $content_image=WP_RSS_MULTI_IMAGES."content_image.png";
    607         $media_image=WP_RSS_MULTI_IMAGES."media_image.png";
    608         $imageExists=0;
    609         $rssmi_global_options = get_option('rssmi_global_options');
    610         $noDirectFetch=(isset($rssmi_global_options['noForcedFeed']) ? $rssmi_global_options['noForcedFeed'] : 0);
    611 
    612        if( ! empty( $feed_url ) ) { 
    613             if ($noDirectFetch==1){
    614                 $feed = fetch_feed($feed_url);
    615             }else{
    616                 $feed = wp_rss_fetchFeed($feed_url,20,true,0); 
     573    global $post;
     574    $feed_url             = get_post_meta( $post->ID, 'rssmi_url', true );
     575    $content_image        = WP_RSS_MULTI_IMAGES . "content_image.png";
     576    $media_image          = WP_RSS_MULTI_IMAGES . "media_image.png";
     577    $imageExists          = 0;
     578    $rssmi_global_options = get_option( 'rssmi_global_options' );
     579    $noDirectFetch        = ( isset( $rssmi_global_options['noForcedFeed'] ) ? $rssmi_global_options['noForcedFeed'] : 0 );
     580
     581    if ( ! empty( $feed_url ) ) {
     582        if ( $noDirectFetch == 1 ) {
     583            $feed = fetch_feed( $feed_url );
     584        }
     585        else {
     586            $feed = wp_rss_fetchFeed( $feed_url, 20, true, 0 );
     587        }
     588
     589        if ( ! $feed->error() ) {
     590            $items     = $feed->get_items();
     591            $feedCount = count( $items );
     592
     593            echo '<h4>Latest 5 available feed items in the RSS feed for ' . get_the_title() . '</h4>';
     594            $count     = 0;
     595            $feedlimit = 5;
     596            foreach ( $items as $item ) {
     597                echo '<ul>';
     598                //      echo '<li>' . $item->get_title() . '</li>';
     599
     600                echo '<li>' . html_entity_decode( $item->get_title() );
     601                if ( rssmi_image_test( $item->get_content() ) == 1 ) {
     602                    echo '  <img src=' . $content_image . '>';
     603                    $imageExists = 1;
     604                }
     605                if ( rss_mediaImage_test( $item ) == 1 ) {
     606                    echo '  <img src=' . $media_image . '>';
     607                    //  echo rssmi_mediaImage_choice($item);  //experimental
     608                    $imageExists = 1;
     609                }
     610
     611                echo '</li>';
     612                echo '</ul>';
     613                if ( ++$count == $feedlimit ) break; //break if count is met
    617614            }
    618 
    619            if ( !$feed->error()) {
    620                 $items = $feed->get_items();   
    621                 $feedCount=count($items);
    622                
    623                echo '<h4>Latest 5 available feed items in the RSS feed for ' . get_the_title() . '</h4>';
    624                $count = 0;
    625                $feedlimit = 5;
    626                foreach ( $items as $item ) {
    627                    echo '<ul>';
    628              //      echo '<li>' . $item->get_title() . '</li>';
    629 
    630             echo '<li>' . html_entity_decode($item->get_title());
    631             if (rssmi_image_test($item->get_content())==1){
    632                 echo '  <img src='.$content_image.'>';
    633                 $imageExists=1;
     615            echo "THIS FEED CURRENTLY HAS A TOTAL OF " . $feedCount . " ITEMS.";
     616            if ( $imageExists == 0 ) {
     617                echo "<br><strong>IMPORTANT</strong> - THIS FEED HAS NO IMAGES (AT LEAST NOT IN THE MOST RECENT 5 POSTS) - SO YOU WILL SEE NO IMAGES IN YOUR POSTS UNLESS YOU USE A DEFAULT CATEGORY IMAGE.";
    634618            }
    635                 if (rss_mediaImage_test($item)==1){
    636                     echo '  <img src='.$media_image.'>';
    637                 //  echo rssmi_mediaImage_choice($item);  //experimental
    638                     $imageExists=1;
    639                 }
    640            
    641             echo '</li>';
    642                    echo '</ul>';
    643                    if( ++$count == $feedlimit ) break; //break if count is met
    644                }
    645 echo "THIS FEED CURRENTLY HAS A TOTAL OF ".$feedCount." ITEMS.";
    646 if ($imageExists==0){
    647 echo "<br><strong>IMPORTANT</strong> - THIS FEED HAS NO IMAGES (AT LEAST NOT IN THE MOST RECENT 5 POSTS) - SO YOU WILL SEE NO IMAGES IN YOUR POSTS UNLESS YOU USE A DEFAULT CATEGORY IMAGE.";   
    648 }
    649            }
    650            else echo "<strong>Invalid feed URL</strong> - Validate the feed source URL by <a href=\"http://validator.w3.org/feed/check.cgi?url=".$feed_url."\" target=\"_blank\">clicking here</a> and if the feed is valid then  <a href=\"http://www.wprssimporter.com/faqs/im-told-the-feed-isnt-valid-or-working/\" target=\"_blank\">go here to learn more about what might be wrong</a>.";
    651        }
    652 
    653        else echo 'No feed URL defined yet';
    654    }
    655 
    656 
    657 
    658 
    659 
    660 function rss_mediaImage_test($item){
    661     $is_media_image=0;
    662 if ($enclosure = $item->get_enclosure())
    663 {
    664     if(!IS_NULL($item->get_enclosure()->get_thumbnails()))
    665         {
    666             $inum=0;
    667             $mediaImageArray=$item->get_enclosure()->get_thumbnails();
    668         //  $mediaImage=$mediaImageArray[$inum];
    669             $is_media_image=1;
    670     } else if (!IS_NULL($item->get_enclosure()->get_link()))
    671         {
    672             $mediaImage=$item->get_enclosure()->get_link();
    673             $is_media_image=1;
    674         }   
     619        }
     620        else echo "<strong>Invalid feed URL</strong> - Validate the feed source URL by <a href=\"http://validator.w3.org/feed/check.cgi?url=" . $feed_url . "\" target=\"_blank\">clicking here</a> and if the feed is valid then  <a href=\"http://www.wprssimporter.com/faqs/im-told-the-feed-isnt-valid-or-working/\" target=\"_blank\">go here to learn more about what might be wrong</a>.";
     621    }
     622
     623    else echo 'No feed URL defined yet';
     624}
     625
     626
     627function rss_mediaImage_test( $item ) {
     628    $is_media_image = 0;
     629    if ( $enclosure = $item->get_enclosure() ) {
     630        if ( ! IS_NULL( $item->get_enclosure()->get_thumbnails() ) ) {
     631            $inum            = 0;
     632            $mediaImageArray = $item->get_enclosure()->get_thumbnails();
     633            //  $mediaImage=$mediaImageArray[$inum];
     634            $is_media_image = 1;
     635        }
     636        else if ( ! IS_NULL( $item->get_enclosure()->get_link() ) ) {
     637            $mediaImage     = $item->get_enclosure()->get_link();
     638            $is_media_image = 1;
     639        }
    675640    }
    676641    return $is_media_image;
     
    678643
    679644
    680 function rssmi_mediaImage_choice($item){
    681     $mediaImageArray=$item->get_enclosure()->get_thumbnails();
    682     for ($inum=0; $inum<=3; $inum++) {
    683     $mediaImage=$mediaImageArray[0];
    684     return $mediaImage;
    685     }
    686 }
    687 
    688 function rssmi_image_test($content){
    689     $leadMatch=0;
    690     $is_image=0;
    691 
    692     $strmatch='^\s*(?:<p.*>)?\<a.*href="(.*)">\s*(<img.*src=[\'"].*[\'"]\s*?\/?>)[^\<]*<\/a\>\s*(.*)$';
    693 
    694     $strmatch2='^(\s*)(?:<p.*>)?(<img.*src=[\'"].*[\'"]\s*?\/?>)\s*(.*)$';
    695 
    696     $strmatch3='^(.*)(<img.*src=[\'"].*[\'"]\s*?\/?>)\s*(.*)$';  //match first image if it exists
    697    
    698         if (preg_match("/$strmatch/sU", $content, $matches)) { //matches a leading hperlinked image
    699             $leadMatch=1;
    700         }else if (preg_match("/$strmatch2/sU", $content, $matches)) {  //matches a leading non-hperlinked image
    701             $leadMatch=2;
    702         }else if (preg_match("/$strmatch3/sU", $content, $matches)) { //matches first image
    703             $leadMatch=3;
    704         }
    705 
    706     if ((isset($leadMatch) && $leadMatch==1) && rssmi_isbug($matches[2])==False){
    707         $is_image=1;   
    708     }else if ((isset($leadMatch) && $leadMatch==2) || (isset($leadMatch) && $leadMatch==3) && rssmi_isbug($matches[2])==False){
    709         $is_image=1;
    710     }
    711    
    712 return $is_image;
    713    
    714 }
    715 
    716 function rssmi_isbug($imageLink){
    717    
    718     if(strpos($imageLink,'width="1"')>0){
    719         $msg = TRUE;
    720     }
    721     else
    722     {
    723         $msg = FALSE;
    724 }
    725      return $msg;
    726 }
    727 
    728 
    729 
    730 
    731 
    732 
    733 
    734 
    735 function rssmi_delete_posts_for_feed(){
    736 (isset($_GET['post'])?$postid=$_GET['post']:$postid=null);
    737 echo    '<div style="float:left"><button type="button" id="delete-feedposts" name="feedID" value="'.$postid.'"  class="button-delete-red" />Delete Feed Items Now</button></div>';
    738 
    739 echo    '<div style="margin-left:50px"><button type="button" id="rssmi-fetch-items-now" name="feedID" value="'.$postid.'"  class="button-fetch-green" />Fetch Feed Items Now</button></div>';
    740 
    741 echo '<div id="feedposts_note"></div><div id="fetch_items_note"></div><div id="rssmi-ajax-loader-delete-fetch"></div>';
    742    
    743     }
    744    
    745    
    746    
    747    
    748    
    749    
    750    
    751     add_action('wp_ajax_rssmi_fetch_items_now', 'fetch_feeds_for_id');
    752 
    753     function fetch_feeds_for_id(){
    754         $post_id=$_POST["pid"];
    755         $rssmi_global_options = get_option('rssmi_global_options');
    756         $max=(isset($rssmi_global_options['single_feed_max']) ? $rssmi_global_options['single_feed_max'] : 20);
    757 
    758         if (isset($post_id)){
    759     wp_rss_multi_importer_post($post_id,$catID=NULL);   
    760     rssmi_fetch_feed_items( $post_id,$max );   
    761     echo "Most recent feed items have been imported";   
    762        
    763         }
    764 
    765 
    766         die();
    767     }
    768    
    769    
    770    
    771    
    772    
    773    
    774     add_action('wp_ajax_delete_feedposts', 'fetch_rss_feed_delete');
    775 
    776     function fetch_rss_feed_delete( ) {
    777         $postit=$_POST["post_var"];  ///holds the Feed ID number
    778         rssmi_delete_all_for_feed($postit);
    779         rssmi_delete_all_posts_for_feed($postit);
    780             //  rssmi_delete_all_for_feed($id);
    781                 echo 'All posts for this feed have been deleted';
    782                 die();
    783     }
    784 
    785 
    786 
    787     function rssmi_check_url_status() {
    788      global $post;
    789      $feed_url = get_post_meta( $post->ID, 'rssmi_url', true );
    790      $checkmark=WP_RSS_MULTI_IMAGES."check_mark.png";
    791      $urlerror=WP_RSS_MULTI_IMAGES."error.png";
    792      if( ! empty( $feed_url ) ) {   
     645function rssmi_mediaImage_choice( $item ) {
     646    $mediaImageArray = $item->get_enclosure()->get_thumbnails();
     647    for ( $inum = 0; $inum <= 3; $inum ++ ) {
     648        $mediaImage = $mediaImageArray[0];
     649        return $mediaImage;
     650    }
     651}
     652
     653function rssmi_image_test( $content ) {
     654    $leadMatch = 0;
     655    $is_image  = 0;
     656
     657    $strmatch = '^\s*(?:<p.*>)?\<a.*href="(.*)">\s*(<img.*src=[\'"].*[\'"]\s*?\/?>)[^\<]*<\/a\>\s*(.*)$';
     658
     659    $strmatch2 = '^(\s*)(?:<p.*>)?(<img.*src=[\'"].*[\'"]\s*?\/?>)\s*(.*)$';
     660
     661    $strmatch3 = '^(.*)(<img.*src=[\'"].*[\'"]\s*?\/?>)\s*(.*)$'; //match first image if it exists
     662
     663    if ( preg_match( "/$strmatch/sU", $content, $matches ) ) { //matches a leading hperlinked image
     664        $leadMatch = 1;
     665    }
     666    else if ( preg_match( "/$strmatch2/sU", $content, $matches ) ) { //matches a leading non-hperlinked image
     667        $leadMatch = 2;
     668    }
     669    else if ( preg_match( "/$strmatch3/sU", $content, $matches ) ) { //matches first image
     670        $leadMatch = 3;
     671    }
     672
     673    if ( ( isset( $leadMatch ) && $leadMatch == 1 ) && rssmi_isbug( $matches[2] ) == False ) {
     674        $is_image = 1;
     675    }
     676    else if ( ( isset( $leadMatch ) && $leadMatch == 2 ) || ( isset( $leadMatch ) && $leadMatch == 3 ) && rssmi_isbug( $matches[2] ) == False ) {
     677        $is_image = 1;
     678    }
     679
     680    return $is_image;
     681
     682}
     683
     684function rssmi_isbug( $imageLink ) {
     685
     686    if ( strpos( $imageLink, 'width="1"' ) > 0 ) {
     687        $msg = TRUE;
     688    }
     689    else {
     690        $msg = FALSE;
     691    }
     692    return $msg;
     693}
     694
     695
     696function rssmi_delete_posts_for_feed() {
     697    ( isset( $_GET['post'] ) ? $postid = $_GET['post'] : $postid = null );
     698    echo '<div style="float:left"><button type="button" id="delete-feedposts" name="feedID" value="' . $postid . '"  class="button-delete-red" />Delete Feed Items Now</button></div>';
     699
     700    echo '<div style="margin-left:50px"><button type="button" id="rssmi-fetch-items-now" name="feedID" value="' . $postid . '"  class="button-fetch-green" />Fetch Feed Items Now</button></div>';
     701
     702    echo '<div id="feedposts_note"></div><div id="fetch_items_note"></div><div id="rssmi-ajax-loader-delete-fetch"></div>';
     703
     704}
     705
     706
     707add_action( 'wp_ajax_rssmi_fetch_items_now', 'fetch_feeds_for_id' );
     708
     709function fetch_feeds_for_id() {
     710    $post_id              = $_POST["pid"];
     711    $rssmi_global_options = get_option( 'rssmi_global_options' );
     712    $max                  = ( isset( $rssmi_global_options['single_feed_max'] ) ? $rssmi_global_options['single_feed_max'] : 20 );
     713
     714    if ( isset( $post_id ) ) {
     715        wp_rss_multi_importer_post( $post_id, $catID = NULL );
     716        rssmi_fetch_feed_items( $post_id, $max );
     717        echo "Most recent feed items have been imported";
     718
     719    }
     720
     721
     722    die();
     723}
     724
     725
     726add_action( 'wp_ajax_delete_feedposts', 'fetch_rss_feed_delete' );
     727
     728function fetch_rss_feed_delete() {
     729    $postit = $_POST["post_var"]; ///holds the Feed ID number
     730    rssmi_delete_all_for_feed( $postit );
     731    rssmi_delete_all_posts_for_feed( $postit );
     732    //  rssmi_delete_all_for_feed($id);
     733    echo 'All posts for this feed have been deleted';
     734    die();
     735}
     736
     737
     738function rssmi_check_url_status() {
     739    global $post;
     740    $feed_url  = get_post_meta( $post->ID, 'rssmi_url', true );
     741    $checkmark = WP_RSS_MULTI_IMAGES . "check_mark.png";
     742    $urlerror  = WP_RSS_MULTI_IMAGES . "error.png";
     743    if ( ! empty( $feed_url ) ) {
    793744//  echo $feed_url;   
    794         $feed = wp_rss_fetchFeed( $feed_url );
    795        //  if ( ! is_wp_error( $feed ) ) {
    796     if (!$feed->error()){
    797                 //  return "<span style=\"color:green\">OK</span>";
    798     //          return "<img src=$checkmark>";
    799             }else{
    800     //          return "<img src=$urlerror>";
    801                 //  return "<span style=\"color:red\">NOT AVAILABLE</span>";
    802             }
    803         }         
    804     }
    805 
    806 
    807 
    808 
    809 
    810     add_action( 'add_meta_boxes', 'rssmi_remove_meta_boxes', 100 );
    811    /*
    812     Remove unneeded meta boxes from add feed source scre
    813     */       
    814    function rssmi_remove_meta_boxes() {
    815       // if ( 'rssmi_feed' !== get_current_screen()->id ) return;     
    816        remove_meta_box( 'sharing_meta', 'rssmi_feed' ,'advanced' );
    817        remove_meta_box( 'content-permissions-meta-box', 'rssmi_feed' ,'advanced' );
    818        remove_meta_box( 'wpseo_meta', 'rssmi_feed' ,'normal' );
    819        remove_meta_box( 'theme-layouts-post-meta-box', 'rssmi_feed' ,'side' );
    820        remove_meta_box( 'post-stylesheets', 'rssmi_feed' ,'side' );
    821        remove_meta_box( 'hybrid-core-post-template', 'rssmi_feed' ,'side' );
    822        remove_meta_box( 'trackbacksdiv22', 'rssmi_feed' ,'advanced' );
    823        remove_action( 'post_submitbox_start', 'fpp_post_submitbox_start_action' );
    824    
    825    }
    826 
    827 
    828    add_filter( 'gettext', 'rssmi_change_publish_button', 10, 2 );
    829    /**
    830     * Change 'Publish' button text
    831     */     
    832    function rssmi_change_publish_button( $translation, $text ) {
    833    if ( 'rssmi_feed' == get_post_type())
    834    if ( $text == 'Publish' )
    835        return 'Add Feed';
    836 
    837    return $translation;
    838    }
    839 
     745        $feed = wp_rss_fetchFeed( $feed_url );
     746        //  if ( ! is_wp_error( $feed ) ) {
     747        if ( ! $feed->error() ) {
     748            //  return "<span style=\"color:green\">OK</span>";
     749            //          return "<img src=$checkmark>";
     750        }
     751        else {
     752            //          return "<img src=$urlerror>";
     753            //  return "<span style=\"color:red\">NOT AVAILABLE</span>";
     754        }
     755    }
     756}
     757
     758
     759add_action( 'add_meta_boxes', 'rssmi_remove_meta_boxes', 100 );
     760/*
     761    Remove unneeded meta boxes from add feed source scre
     762    */
     763function rssmi_remove_meta_boxes() {
     764    // if ( 'rssmi_feed' !== get_current_screen()->id ) return;
     765    remove_meta_box( 'sharing_meta', 'rssmi_feed', 'advanced' );
     766    remove_meta_box( 'content-permissions-meta-box', 'rssmi_feed', 'advanced' );
     767    remove_meta_box( 'wpseo_meta', 'rssmi_feed', 'normal' );
     768    remove_meta_box( 'theme-layouts-post-meta-box', 'rssmi_feed', 'side' );
     769    remove_meta_box( 'post-stylesheets', 'rssmi_feed', 'side' );
     770    remove_meta_box( 'hybrid-core-post-template', 'rssmi_feed', 'side' );
     771    remove_meta_box( 'trackbacksdiv22', 'rssmi_feed', 'advanced' );
     772    remove_action( 'post_submitbox_start', 'fpp_post_submitbox_start_action' );
     773
     774}
     775
     776
     777add_filter( 'gettext', 'rssmi_change_publish_button', 10, 2 );
     778
     779/**
     780 * Change 'Publish' button text
     781 */
     782function rssmi_change_publish_button( $translation, $text ) {
     783    if ( 'rssmi_feed' == get_post_type() )
     784        if ( $text == 'Publish' )
     785            return 'Add Feed';
     786
     787    return $translation;
     788}
    840789
    841790
    842791function rssmi_my_admin() {
    843 add_meta_box( 'rssmi_feed_meta_box',
    844 'Feed Source Details',
    845 'display_rssmi_feed_meta_box',
    846 'rssmi_feeds', 'normal', 'high' );
    847 }
     792    add_meta_box( 'rssmi_feed_meta_box',
     793        'Feed Source Details',
     794        'display_rssmi_feed_meta_box',
     795        'rssmi_feeds', 'normal', 'high' );
     796}
     797
     798add_action( 'admin_init', 'rssmi_my_admin' );
    848799
    849800function display_rssmi_feed_meta_box( $rssmi_feed ) {
    850  echo '<input type="hidden" name="rssmi_meta_box_nonce" value="' . wp_create_nonce( basename( __FILE__ ) ) . '" />';
    851 $rssmi_url =
    852 esc_html( get_post_meta( $rssmi_feed->ID,
    853 'rssmi_url', true ) );
    854 $rssmi_cat =
    855 intval( get_post_meta( $rssmi_feed->ID,
    856 'rssmi_cat', true ) );
    857 $rssmi_user =
    858 intval( get_post_meta( $rssmi_feed->ID,
    859 'rssmi_user', true ) );
    860 $rssmi_mediaID =
    861 intval( get_post_meta( $rssmi_feed->ID,
    862 'rssmi_mediaID', true ) );
    863 ?>
    864 <table>
    865 <tr>
    866 <td style="width: 20%">Feed URL</td>
    867 <td><input type="text" size="50"
    868 name="rssmi_url"
    869 value="<?php echo $rssmi_url; ?>" /><?php if (isset($rssmi_url) && $rssmi_url!=''){echo 'Validate this feed source URL by <a href="http://feedvalidator.org/check?url='.$rssmi_url.'" target="_blank">clicking here</a>';}?></td>
    870 </tr>
    871 <tr>
    872 <td style="width: 20%">Feed Category</td>
    873 <td>
    874 <select style="width: 200px"
    875 name="rssmi_cat">
    876     <OPTION selected VALUE=''>None</OPTION>
    877 <?php
    878 // Generate all items of drop-down list
    879 $catOptions= get_option( 'rss_import_categories' );
    880 if (!empty($catOptions)){
    881 $catsize = count($catOptions);
    882 for ( $k=1; $k<=$catsize; $k++) { 
    883     if( $k % 2== 0 ) continue;
    884     $catkey = key( $catOptions );
    885     $nameValue=$catOptions[$catkey];
    886     next( $catOptions );
    887     $catkey = key( $catOptions );
    888     $IDValue=$catOptions[$catkey];
    889 ?>
    890 <option value="<?php echo $IDValue; ?>"
    891 <?php echo selected( $IDValue,
    892 $rssmi_cat ); ?>>
    893 <?php echo $nameValue; ?>
    894 <?php
    895 next( $catOptions );
    896 }}?>
    897 </select> <?php if (empty($catOptions)){echo 'If you added categories, you can assign this feed to a category. <a href="admin.php?page=wprssmi_options">Go here to set up categories.</a>';}?>
    898 </td>
    899 </tr>
    900 
    901 <tr>
    902 <td style="width: 20%">Blog User</td>
    903 <td>
    904 <select style="width: 200px"
    905 name="rssmi_user">
    906 <?php
    907 $blogusers = get_users( array( 'orderby' => 'ID' ) );
    908 foreach ($blogusers as $user){
     801    echo '<input type="hidden" name="rssmi_meta_box_nonce" value="' . wp_create_nonce( basename( __FILE__ ) ) . '" />';
     802    $rssmi_url     =
     803        esc_html( get_post_meta( $rssmi_feed->ID,
     804            'rssmi_url', true ) );
     805    $rssmi_cat     =
     806        intval( get_post_meta( $rssmi_feed->ID,
     807            'rssmi_cat', true ) );
     808    $rssmi_user    =
     809        intval( get_post_meta( $rssmi_feed->ID,
     810            'rssmi_user', true ) );
     811    $rssmi_mediaID =
     812        intval( get_post_meta( $rssmi_feed->ID,
     813            'rssmi_mediaID', true ) );
    909814    ?>
    910     <option value="<?php echo $user->ID; ?>"
    911     <?php echo selected( $user->ID,
    912     $rssmi_user ); ?>>
    913     <?php echo $user->display_name; ?>
    914 <?php   } ?>
    915     </select> (for use on AutoPost)
    916 </td>
    917 </tr>
    918 
    919 <tr>
    920     <td style="width: 20%">Media Image Number</td>
    921     <td>   
    922         <select style="width: 200px" name="rssmi_mediaID">
    923             <option value="">Default</option>
    924         <?php
    925         for ($i = 1 ; $i<=5;$i++){
    926             ?>
    927             <option value="<?php echo $i; ?>"
    928             <?php echo selected( $i,
    929             $rssmi_mediaID ); ?>>
    930             <?php echo $i; ?>
    931         <?php   } ?>
    932             </select> (for Media Image - selects which media image in the feed's image enclosure.  If you choose an image number, this will be used over any other image found.  <a href="http://www.wprssimporter.com/faqs/what-is-the-media-image-number/" target="_blank">Learn more about this here.</a>)
    933 </td>
    934 </tr>
    935 
    936 
    937 
    938 
    939 
    940 </table>
    941 <?php }
    942 
    943 
    944 
    945 
    946 
    947 function rssmi_custom_fields() {
    948     $prefix = 'rssmi_';
    949    
    950     $rssmi_meta_fields['url'] = array(
    951         'label' => __( 'URL', 'rssmi' ),
    952         'id'    => $prefix.'url'
    953     );
    954     $rssmi_meta_fields['cat'] = array(
    955         'label' => __( 'Category', 'rssmi' ),
    956         'id'    => $prefix.'cat'
    957     ); 
    958     $rssmi_meta_fields['user'] = array(
    959         'label' => __( 'User', 'rssmi' ),
    960         'id'    => $prefix.'user'
    961     ); 
    962 
    963     $rssmi_meta_fields['mediaID'] = array(
    964         'label' => __( 'mediaID', 'rssmi' ),
    965         'id'    => $prefix.'mediaID'
    966     );
    967 
    968 
    969     return $rssmi_meta_fields;
    970 }
    971 
    972 
    973 
    974 
    975 //add_action('delete_post', 'rssmi_trash_function');  //  Needs work
    976 
    977 function rssmi_trash_function($post_id){
    978     wp_delete_post($post_id, true);
    979 }
    980 
    981 function rssmi_delete_prior_posts($post_id){
    982      global $wpdb;
    983         $query = "SELECT post_id FROM $wpdb->postmeta WHERE meta_key='rssmi_source_feed' AND meta_value = $post_id";
    984         $prior_posts =$wpdb->get_results($query);
    985         foreach ($prior_posts as $prior_post){
    986             wp_delete_post($prior_post->post_id, true);
    987         }
    988 }
    989 
    990 
    991 add_action( 'save_post', 'rssmi_save_custom_fields' );
    992  
    993     function rssmi_save_custom_fields( $post_id ) {
    994 
    995         $meta_fields = rssmi_custom_fields();
    996 
    997        
    998         if ($_POST['post_type'] !='rssmi_feed') {
    999                 return;
    1000             }
    1001    
    1002    
    1003         $rssmi_nonce_var=(isset($_POST[ 'rssmi_meta_box_nonce' ]) ? $_POST[ 'rssmi_meta_box_nonce' ] :NULL);
    1004         // verify nonce
    1005       if ( ! wp_verify_nonce( $rssmi_nonce_var, basename( __FILE__ ) ) )
    1006 //if ( ! wp_verify_nonce ($_POST[ 'rssmi_meta_box_nonce' ], basename( __FILE__ ) ) )
    1007             return $post_id;
    1008        
    1009         // check autosave
    1010         if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE)
    1011             return $post_id;
    1012        
    1013         // check permissions
    1014         if ( 'page' == $_POST[ 'post_type' ] ) {
    1015             if ( ! current_user_can( 'edit_page', $post_id ) )
    1016                 return $post_id;
    1017             } elseif ( ! current_user_can( 'edit_post', $post_id ) ) {
    1018                 return $post_id;
    1019         }
    1020 
    1021         // delete prior posts if this post_id url changes
    1022         $oldURL = get_post_meta( $post_id, 'rssmi_url', true );
    1023         $newURL=$_POST['rssmi_url' ];
    1024         if($newURL && $newURL != $oldURL){
    1025             rssmi_delete_all_for_feed($post_id);
    1026             rssmi_delete_prior_posts($post_id);
    1027         }
    1028 
    1029         // loop through fields and save the data
    1030         foreach ( $meta_fields as $field ) {
    1031             $old = get_post_meta( $post_id, $field[ 'id' ], true );
    1032             $new = $_POST[ $field[ 'id' ] ];
    1033             if ( $new && $new != $old ) {
    1034                 update_post_meta( $post_id, $field[ 'id' ], $new );
    1035             } elseif ( '' == $new && $old ) {
    1036                 delete_post_meta( $post_id, $field[ 'id' ], $old );
    1037             }
    1038         } // end foreach
    1039    
    1040     }
    1041 
    1042 
    1043 add_action( 'before_delete_post', 'rssmi_delete_custom_fields');
    1044 
    1045     function rssmi_delete_custom_fields($postid){
    1046         global $wpdb;
    1047         $delete_array = $wpdb->get_results("SELECT post_id FROM $wpdb->postmeta WHERE meta_key='rssmi_source_feed' AND meta_value =$postid");
    1048         foreach($delete_array as $delete_item){
    1049             wp_delete_post($delete_item->post_id, true);
    1050         }
    1051     }
    1052 
    1053 
    1054     add_filter("manage_edit-rssmi_feed_item_sortable_columns", 'rssmi_shortcode_sortable_columns');
    1055 
    1056          
    1057            function rssmi_shortcode_sortable_columns($columns)
    1058         {
    1059           $custom = array(
    1060                 // meta column id => sortby value used in query
    1061             'publishdate'    => 'publishdate',
    1062           );
    1063 
    1064           return wp_parse_args($custom, $columns);
    1065         }   
    1066 
    1067         add_action( 'pre_get_posts', 'rssmi_feed_source_order' );
    1068        
    1069         function rssmi_feed_source_order( $query ) {
    1070             if( ! is_admin() )
    1071                 return;
    1072             $post_type = $query->get('post_type');
    1073             if ( $post_type == 'rssmi_feed_item') {
    1074                 $query->set('orderby','publishdate');
    1075                 $orderby = $query->get( 'orderby');
    1076                 if( 'publishdate' == $orderby ) {
    1077                     $query->set( 'meta_key', 'rssmi_item_date' );
    1078                     $query->set( 'orderby', 'meta_value_num' );
    1079                 }
    1080             }
    1081         }
    1082        
    1083     //  ADD THIS ONLY IF YOU DO NOT WANT SHORTCODE POSTS TO BE SEARCHABLE   
    1084    
    1085     //  add_filter('pre_get_posts', 'rssmi_search_filter');
    1086        
    1087         function rssmi_search_filter($query){
    1088         if ( is_search() && !is_admin()){
    1089             if ( $query->is_search ){
    1090                 $post_types=get_post_types();
    1091                 unset($post_types['rssmi_feed_item']);
    1092                 $query->set('post_type',$post_types);
    1093                 return $query;
    1094             }
    1095         }   
    1096         }
    1097    
    1098     //  This function makes searchable shortcode posts click directly to the feed source
    1099        
    1100         add_filter( 'the_title', 'rssmi_search_modified_post_title'); 
    1101        
    1102         function rssmi_search_modified_post_title ($title) {
    1103           if (in_the_loop() && is_search() && !is_admin()) {   
    1104             $post_options = get_option('rss_import_items');
    1105             $targetWindow=$options['targetWindow'];  // 0=LB, 1=same, 2=new
    1106                 if($targetWindow==0){
    1107                     $openWindow='class="colorbox"';
    1108                 }elseif ($targetWindow==1){
    1109                     $openWindow='target=_self';     
    1110                 }else{
    1111                     $openWindow='target=_blank ';   
    1112                 }
    1113             global $wp_query;
    1114             $postID=$wp_query->post->ID;
    1115             $myLink = get_post_meta( $postID, 'rssmi_item_permalink', true);
    1116                 if (!empty($myLink)){
    1117                     $myTitle=$wp_query->post->post_title;
    1118                     $myLinkTitle='<a href='.$myLink.' '.$openWindow.'>'.$myTitle.'</a>';  // change how the link opens here
    1119                 return $myLinkTitle;                   
    1120                     }
    1121           }
    1122           return $title;
    1123         }
    1124        
    1125        
    1126        
    1127         //**  Bulk edit of Feed Properties **/
    1128        
    1129         add_action( 'bulk_edit_custom_box', 'display_custom_quickedit_category', 10, 2 );
    1130 
    1131         function display_custom_quickedit_category( $column_name, $post_type ) {
    1132           /*  static $printNonce = TRUE;
    1133             if ( $printNonce ) {
    1134                 $printNonce = FALSE;
    1135                 wp_nonce_field( plugin_basename( __FILE__ ), 'category_edit_nonce' );
    1136             }
    1137 */
    1138             ?>
    1139             <fieldset class="inline-edit-col-right inline-edit-category">
    1140               <div class="inline-edit-col column-<?php echo $column_name ?>">
    1141                 <label class="inline-edit-group">
    1142                 <?php
    1143                  switch ( $column_name ) {
    1144                  case 'category':
    1145                      ?><span class="title">Category</span>
    1146        
    1147                     <select style="width: 200px"
    1148                     name="rssmi_cat">
    1149                         <OPTION selected VALUE=''>-- No Change --</OPTION>
     815    <table>
     816        <tr>
     817            <td style="width: 20%">Feed URL</td>
     818            <td><input type="text" size="50"
     819                       name="rssmi_url"
     820                       value="<?php echo $rssmi_url; ?>" /><?php if ( isset( $rssmi_url ) && $rssmi_url != '' ) {
     821                    echo 'Validate this feed source URL by <a href="http://feedvalidator.org/check?url=' . $rssmi_url . '" target="_blank">clicking here</a>';
     822                } ?></td>
     823        </tr>
     824        <tr>
     825            <td style="width: 20%">Feed Category</td>
     826            <td>
     827                <select style="width: 200px"
     828                        name="rssmi_cat">
     829                    <OPTION selected VALUE=''>None</OPTION>
    1150830                    <?php
    1151831                    // Generate all items of drop-down list
    1152                     $catOptions= get_option( 'rss_import_categories' );
    1153                     if (!empty($catOptions)){
    1154                     $catsize = count($catOptions);
    1155                     for ( $k=1; $k<=$catsize; $k++) { 
    1156                         if( $k % 2== 0 ) continue;
    1157                         $catkey = key( $catOptions );
    1158                         $nameValue=$catOptions[$catkey];
    1159                         next( $catOptions );
    1160                         $catkey = key( $catOptions );
    1161                         $IDValue=$catOptions[$catkey];
     832                    $catOptions = get_option( 'rss_import_categories' );
     833                    if (! empty( $catOptions )){
     834                    $catsize = count( $catOptions );
     835                    for ($k = 1;
     836                    $k <= $catsize;
     837                    $k ++) {
     838                    if ( $k % 2 == 0 ) continue;
     839                    $catkey = key( $catOptions );
     840                    $nameValue = $catOptions[$catkey];
     841                    next( $catOptions );
     842                    $catkey = key( $catOptions );
     843                    $IDValue = $catOptions[$catkey];
    1162844                    ?>
    1163845                    <option value="<?php echo $IDValue; ?>"
    1164                     <?php echo selected( $IDValue,
    1165                     $rssmi_cat ); ?>>
    1166                     <?php echo $nameValue; ?>
     846                        <?php echo selected( $IDValue,
     847                            $rssmi_cat ); ?>>
     848                        <?php echo $nameValue; ?>
     849                        <?php
     850                        next( $catOptions );
     851                        }
     852                        }?>
     853                </select> <?php if ( empty( $catOptions ) ) {
     854                    echo 'If you added categories, you can assign this feed to a category. <a href="admin.php?page=wprssmi_options">Go here to set up categories.</a>';
     855                } ?>
     856            </td>
     857        </tr>
     858
     859        <tr>
     860            <td style="width: 20%">Blog User</td>
     861            <td>
     862                <select style="width: 200px"
     863                        name="rssmi_user">
    1167864                    <?php
    1168                     next( $catOptions );
    1169                     }}?>
    1170                     </select>       
    1171        
    1172         <?php
    1173                      break;
    1174              //   case 'inprint':
    1175                     ?>
    1176         <?php
    1177                     // break;
    1178                  }
    1179                 ?>
    1180                 </label>
    1181               </div>
    1182             </fieldset>
    1183             <?php
    1184         }
    1185        
    1186        
    1187         add_action( 'wp_ajax_save_bulk_edit_category', 'save_bulk_edit_category' );
    1188         function save_bulk_edit_category() {
    1189             // TODO perform nonce checking
    1190             // get our variables
    1191            
    1192             $post_ids           = ( ! empty( $_POST[ 'post_ids' ] ) ) ? $_POST[ 'post_ids' ] : array();
    1193             $category  = ( ! empty( $_POST[ 'category' ] ) ) ? $_POST[ 'category' ] : null;
    1194 
    1195 
    1196             // if everything is in order
    1197             if ( ! empty( $post_ids ) && is_array( $post_ids ) ) {
    1198                 foreach( $post_ids as $post_id ) {
    1199                     if (!is_null($category)){
    1200                         update_post_meta( $post_id, 'rssmi_cat', $category );
    1201                     }
    1202 
     865                    $blogusers = get_users( array( 'orderby' => 'ID' ) );
     866                    foreach ($blogusers as $user){
     867                    ?>
     868                    <option value="<?php echo $user->ID; ?>"
     869                        <?php echo selected( $user->ID,
     870                            $rssmi_user ); ?>>
     871                        <?php echo $user->display_name; ?>
     872                        <?php } ?>
     873                </select> (for use on AutoPost)
     874            </td>
     875        </tr>
     876
     877        <tr>
     878            <td style="width: 20%">Media Image Number</td>
     879            <td>
     880                <select style="width: 200px" name="rssmi_mediaID">
     881                    <option value="">Default</option>
     882                    <?php
     883                    for ($i = 1;
     884                    $i <= 5;
     885                    $i ++){
     886                    ?>
     887                    <option value="<?php echo $i; ?>"
     888                        <?php echo selected( $i,
     889                            $rssmi_mediaID ); ?>>
     890                        <?php echo $i; ?>
     891                        <?php } ?>
     892                </select> (for Media Image - selects which media image in the feed's image enclosure. If you choose an image number, this will be used over any other image found.
     893                <a href="http://www.wprssimporter.com/faqs/what-is-the-media-image-number/" target="_blank">Learn more about this here.</a>)
     894            </td>
     895        </tr>
     896
     897
     898    </table>
     899<?php
     900}
     901
     902
     903function rssmi_custom_fields() {
     904    $prefix = 'rssmi_';
     905
     906    $rssmi_meta_fields['url']  = array(
     907        'label' => __( 'URL', 'rssmi' ),
     908        'id'    => $prefix . 'url'
     909    );
     910    $rssmi_meta_fields['cat']  = array(
     911        'label' => __( 'Category', 'rssmi' ),
     912        'id'    => $prefix . 'cat'
     913    );
     914    $rssmi_meta_fields['user'] = array(
     915        'label' => __( 'User', 'rssmi' ),
     916        'id'    => $prefix . 'user'
     917    );
     918
     919    $rssmi_meta_fields['mediaID'] = array(
     920        'label' => __( 'mediaID', 'rssmi' ),
     921        'id'    => $prefix . 'mediaID'
     922    );
     923
     924
     925    return $rssmi_meta_fields;
     926}
     927
     928
     929//add_action('delete_post', 'rssmi_trash_function');  //  Needs work
     930
     931function rssmi_trash_function( $post_id ) {
     932    wp_delete_post( $post_id, true );
     933}
     934
     935function rssmi_delete_prior_posts( $post_id ) {
     936    global $wpdb;
     937    $query       = "SELECT post_id FROM $wpdb->postmeta WHERE meta_key='rssmi_source_feed' AND meta_value = $post_id";
     938    $prior_posts = $wpdb->get_results( $query );
     939    foreach ( $prior_posts as $prior_post ) {
     940        wp_delete_post( $prior_post->post_id, true );
     941    }
     942}
     943
     944
     945add_action( 'save_post', 'rssmi_save_custom_fields' );
     946
     947function rssmi_save_custom_fields( $post_id ) {
     948
     949    $meta_fields = rssmi_custom_fields();
     950
     951
     952    if ( isset( $_POST['post_type'] ) && $_POST['post_type'] != 'rssmi_feed' ) {
     953        return;
     954    }
     955
     956
     957    $rssmi_nonce_var = ( isset( $_POST['rssmi_meta_box_nonce'] ) ? $_POST['rssmi_meta_box_nonce'] : NULL );
     958    // verify nonce
     959    if ( ! wp_verify_nonce( $rssmi_nonce_var, basename( __FILE__ ) ) )
     960//if ( ! wp_verify_nonce ($_POST[ 'rssmi_meta_box_nonce' ], basename( __FILE__ ) ) )
     961    return $post_id;
     962
     963    // check autosave
     964    if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
     965        return $post_id;
     966
     967    // check permissions
     968    if ( 'page' == $_POST['post_type'] ) {
     969        if ( ! current_user_can( 'edit_page', $post_id ) )
     970            return $post_id;
     971    }
     972    elseif ( ! current_user_can( 'edit_post', $post_id ) ) {
     973        return $post_id;
     974    }
     975
     976    // delete prior posts if this post_id url changes
     977    $oldURL = get_post_meta( $post_id, 'rssmi_url', true );
     978    $newURL = $_POST['rssmi_url'];
     979    if ( $newURL && $newURL != $oldURL ) {
     980        rssmi_delete_all_for_feed( $post_id );
     981        rssmi_delete_prior_posts( $post_id );
     982    }
     983
     984    // loop through fields and save the data
     985    foreach ( $meta_fields as $field ) {
     986        $old = get_post_meta( $post_id, $field['id'], true );
     987        $new = $_POST[$field['id']];
     988        if ( $new && $new != $old ) {
     989            update_post_meta( $post_id, $field['id'], $new );
     990        }
     991        elseif ( '' == $new && $old ) {
     992            delete_post_meta( $post_id, $field['id'], $old );
     993        }
     994    } // end foreach
     995
     996}
     997
     998
     999add_action( 'before_delete_post', 'rssmi_delete_custom_fields' );
     1000
     1001function rssmi_delete_custom_fields( $postid ) {
     1002    global $wpdb;
     1003    $delete_array = $wpdb->get_results( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key='rssmi_source_feed' AND meta_value =$postid" );
     1004    foreach ( $delete_array as $delete_item ) {
     1005        wp_delete_post( $delete_item->post_id, true );
     1006    }
     1007}
     1008
     1009
     1010add_action( 'before_delete_post', 'rssmi_delete_posts_admin_attachment' ); //this function in db_functions.php file
     1011
     1012
     1013add_filter( "manage_edit-rssmi_feed_item_sortable_columns", 'rssmi_shortcode_sortable_columns' );
     1014
     1015
     1016function rssmi_shortcode_sortable_columns( $columns ) {
     1017    $custom = array(
     1018        // meta column id => sortby value used in query
     1019        'publishdate' => 'publishdate',
     1020    );
     1021
     1022    return wp_parse_args( $custom, $columns );
     1023}
     1024
     1025add_action( 'pre_get_posts', 'rssmi_feed_source_order' );
     1026
     1027function rssmi_feed_source_order( $query ) {
     1028    if ( ! is_admin() )
     1029        return;
     1030    $post_type = $query->get( 'post_type' );
     1031    if ( $post_type == 'rssmi_feed_item' ) {
     1032        $query->set( 'orderby', 'publishdate' );
     1033        $orderby = $query->get( 'orderby' );
     1034        if ( 'publishdate' == $orderby ) {
     1035            $query->set( 'meta_key', 'rssmi_item_date' );
     1036            $query->set( 'orderby', 'meta_value_num' );
     1037        }
     1038    }
     1039}
     1040
     1041//  ADD THIS ONLY IF YOU DO NOT WANT SHORTCODE POSTS TO BE SEARCHABLE
     1042
     1043//  add_filter('pre_get_posts', 'rssmi_search_filter');
     1044
     1045function rssmi_search_filter( $query ) {
     1046    if ( is_search() && ! is_admin() ) {
     1047        if ( $query->is_search ) {
     1048            $post_types = get_post_types();
     1049            unset( $post_types['rssmi_feed_item'] );
     1050            $query->set( 'post_type', $post_types );
     1051            return $query;
     1052        }
     1053    }
     1054}
     1055
     1056//  This function makes searchable shortcode posts click directly to the feed source
     1057
     1058add_filter( 'the_title', 'rssmi_search_modified_post_title' );
     1059
     1060function rssmi_search_modified_post_title( $title ) {
     1061    if ( in_the_loop() && is_search() && ! is_admin() ) {
     1062        $post_options = get_option( 'rss_import_items' );
     1063        $targetWindow = $options['targetWindow']; // 0=LB, 1=same, 2=new
     1064        if ( $targetWindow == 0 ) {
     1065            $openWindow = 'class="colorbox"';
     1066        }
     1067        elseif ( $targetWindow == 1 ) {
     1068            $openWindow = 'target=_self';
     1069        }
     1070        else {
     1071            $openWindow = 'target=_blank ';
     1072        }
     1073        global $wp_query;
     1074        $postID = $wp_query->post->ID;
     1075        $myLink = get_post_meta( $postID, 'rssmi_item_permalink', true );
     1076        if ( ! empty( $myLink ) ) {
     1077            $myTitle     = $wp_query->post->post_title;
     1078            $myLinkTitle = '<a href=' . $myLink . ' ' . $openWindow . '>' . $myTitle . '</a>'; // change how the link opens here
     1079            return $myLinkTitle;
     1080        }
     1081    }
     1082    return $title;
     1083}
     1084
     1085
     1086//**  Bulk edit of Feed Properties **/
     1087
     1088add_action( 'bulk_edit_custom_box', 'display_custom_quickedit_category', 10, 2 );
     1089
     1090function display_custom_quickedit_category( $column_name, $post_type ) {
     1091    /*  static $printNonce = TRUE;
     1092        if ( $printNonce ) {
     1093            $printNonce = FALSE;
     1094            wp_nonce_field( plugin_basename( __FILE__ ), 'category_edit_nonce' );
     1095        }
     1096*/
     1097    ?>
     1098    <fieldset class="inline-edit-col-right inline-edit-category">
     1099        <div class="inline-edit-col column-<?php echo $column_name ?>">
     1100            <label class="inline-edit-group">
     1101                <?php
     1102                switch ( $column_name ) {
     1103                    case 'category':
     1104                        ?><span class="title">Category</span>
     1105
     1106                        <select style="width: 200px"
     1107                                name="rssmi_cat">
     1108                            <OPTION selected VALUE=''>-- No Change --</OPTION>
     1109                            <?php
     1110                            // Generate all items of drop-down list
     1111                            $catOptions = get_option( 'rss_import_categories' );
     1112                            if (! empty( $catOptions )){
     1113                            $catsize = count( $catOptions );
     1114                            for ($k = 1;
     1115                            $k <= $catsize;
     1116                            $k ++) {
     1117                            if ( $k % 2 == 0 ) continue;
     1118                            $catkey = key( $catOptions );
     1119                            $nameValue = $catOptions[$catkey];
     1120                            next( $catOptions );
     1121                            $catkey = key( $catOptions );
     1122                            $IDValue = $catOptions[$catkey];
     1123                            ?>
     1124                            <option value="<?php echo $IDValue; ?>"
     1125                                <?php echo selected( $IDValue,
     1126                                    $rssmi_cat ); ?>>
     1127                                <?php echo $nameValue; ?>
     1128                                <?php
     1129                                next( $catOptions );
     1130                                }
     1131                                }?>
     1132                        </select>
     1133
     1134                        <?php
     1135                        break;
     1136                        //   case 'inprint':
     1137                        ?>
     1138                    <?php
     1139                    // break;
    12031140                }
     1141                ?>
     1142            </label>
     1143        </div>
     1144    </fieldset>
     1145<?php
     1146}
     1147
     1148
     1149add_action( 'wp_ajax_save_bulk_edit_category', 'save_bulk_edit_category' );
     1150function save_bulk_edit_category() {
     1151    // TODO perform nonce checking
     1152    // get our variables
     1153
     1154    $post_ids = ( ! empty( $_POST['post_ids'] ) ) ? $_POST['post_ids'] : array();
     1155    $category = ( ! empty( $_POST['category'] ) ) ? $_POST['category'] : null;
     1156
     1157
     1158    // if everything is in order
     1159    if ( ! empty( $post_ids ) && is_array( $post_ids ) ) {
     1160        foreach ( $post_ids as $post_id ) {
     1161            if ( ! is_null( $category ) ) {
     1162                update_post_meta( $post_id, 'rssmi_cat', $category );
    12041163            }
    12051164
    1206             die();
    1207         }
    1208        
    1209        
    1210        
    1211     add_filter('pre_get_posts', 'myfilter');
    1212    
    1213    
    1214     function myfilter($query) {
    1215             $feed_id  = ( ! empty( $_GET[ 'rssmi_feed_id' ] ) ) ? $_GET[ 'rssmi_feed_id' ] : null;
    1216        
    1217             if (isset($_GET['post_type']) && ($_GET['post_type']=='rssmi_feed_item')) {
    1218                 if(is_admin() ) {
    1219                     $query->set('meta_key', 'rssmi_item_feed_id');
    1220                     $query->set('meta_value', $feed_id);
    1221 
    1222                 }
    1223             }
    1224                 return $query;
    1225         }
    1226        
    1227        
    1228    
     1165        }
     1166    }
     1167
     1168    die();
     1169}
     1170
     1171
     1172add_filter( 'pre_get_posts', 'myfilter' );
     1173
     1174
     1175function myfilter( $query ) {
     1176    $feed_id = ( ! empty( $_GET['rssmi_feed_id'] ) ) ? $_GET['rssmi_feed_id'] : null;
     1177
     1178    if ( isset( $_GET['post_type'] ) && ( $_GET['post_type'] == 'rssmi_feed_item' ) ) {
     1179        if ( is_admin() ) {
     1180            $query->set( 'meta_key', 'rssmi_item_feed_id' );
     1181            $query->set( 'meta_value', $feed_id );
     1182
     1183        }
     1184    }
     1185    return $query;
     1186}
     1187
     1188
    12291189?>
  • wp-rss-multi-importer/trunk/inc/db_functions.php

    r976190 r989112  
    11<?php
    22
    3 
    4 
    5 
    6 
    7 
    8 
    9 
     3// TODO: Refactor into an AJAX file, namespace the action
    104function rssmi_restore_all_delete() {
    11 rssmi_restore_all();
    12 }
    13 
    14 
    15 
    16 add_action('wp_ajax_restore_all', 'restore_all_callback_delete');
    17 
     5    rssmi_restore_all();
     6}
     7
     8add_action( 'wp_ajax_restore_all', 'restore_all_callback_delete' );
     9
     10
     11// TODO: Refactor into an AJAX file, namespace the action
    1812function restore_all_callback_delete() {
    1913
    20             rssmi_restore_all_delete();
    21             echo '<h3>Everything has been deleted.</h3>';
    22             die();
    23 }
    24 
    25 
    26 
    27 
    28 add_action('wp_ajax_getFeeds_Now', 'rssmi_import_all_feed_items');
    29 
     14    rssmi_restore_all_delete();
     15    echo '<strong>Everything has been deleted.</strong>';
     16    die();
     17}
     18
     19add_action( 'wp_ajax_getFeeds_Now', 'rssmi_import_all_feed_items' );
     20
     21
     22// TODO: Refactor into an AJAX file, namespace the action
    3023function rssmi_import_all_feed_items() {
    31                 rssmi_fetch_all_feed_items();
    32                 echo '<h3>The feeds database has been updated.</h3>';
    33             die();
    34 
    35 }
    36 
    37 
    38 
    39 add_action('wp_ajax_deleteFeeds_Now', 'rssmi_delete_all_feed_items');
    40 
     24    rssmi_fetch_all_feed_items();
     25    echo '<strong>The feeds database has been updated.</strong>';
     26    die();
     27
     28}
     29
     30add_action( 'wp_ajax_deleteFeeds_Now', 'rssmi_delete_all_feed_items' );
     31
     32
     33// TODO: Refactor into an AJAX file, namespace the action
    4134function rssmi_delete_all_feed_items() {
    42                 rssmi_delete_all_custom_posts();
    43                 echo '<h3>The feeds database has been cleared.</h3>';
    44             die();
    45 
    46 }
    47 
    48 
    49 
    50 add_action('wp_ajax_upgrade_feeds', 'upgradefeeds_callback_activate');
    51 
     35    rssmi_delete_all_custom_posts();
     36    echo '<strong>The feeds database has been cleared.</strong>';
     37    die();
     38
     39}
     40
     41add_action( 'wp_ajax_upgrade_feeds', 'upgradefeeds_callback_activate' );
     42
     43
     44// TODO: Refactor into an AJAX file, namespace the action
    5245function upgradefeeds_callback_activate() {
    5346
    54             rssmi_activate_upgrade();
    55            
    56             echo '<h3>Your data has been transferred.</h3><div style="margin-left:60px;"><input type="submit" name="submit" value="Reload This Page Now" onClick="window.location.reload()" /></div>';
    57             die();
    58 }
    59 
    60 
    61 
    62 
    63 
    64 
    65 function delete_db_transients() {
    66 
    67     global $wpdb;
    68 
    69  
    70     $expired = $wpdb->get_col( "SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE '_transient_wprssmi_%';" );
    71 
    72     foreach( $expired as $transient ) {
    73 
    74         $key = str_replace('_transient_', '', $transient);
    75         delete_transient($key);
    76 
    77     }
    78 }
    79 
    80 
    81 function rssmi_list_the_plugins() {
    82     $plugins = get_option ( 'active_plugins', array () );
    83     foreach ( $plugins as $plugin ) {
    84         echo "<li>$plugin</li>";
    85     }
    86 }
    87 
    88 
    89 
    90 
    91 
    92 function rssmi_list_options(){
    93    
    94      $options = get_option( 'rss_import_options' );
    95    
    96      foreach ( $options as $option ) {
    97             echo "<li>$option</li>";
    98         }
    99    
    100 }
    101 
    102 function rssmi_change_post_status($post_id,$status){
    103     $current_post = get_post( $post_id, 'ARRAY_A' );
    104     $current_post['post_status'] = $status;
    105     wp_update_post($current_post);
    106 }
    107 
    108 
    109 
    110 function rssmi_delete_attachment($id_ID){
    111     $args = array( 'post_type' => 'attachment', 'numberposts' => -1, 'post_status' =>'any', 'post_parent' => $id_ID );
    112     $attachments = get_posts($args);           
    113     if ($attachments) {
    114         foreach ( $attachments as $attachment ) {
    115              wp_delete_attachment($attachment->ID,true);
     47    rssmi_activate_upgrade();
     48
     49    echo '<h3>Your data has been transferred.</h3><div style="margin-left:60px;"><input type="submit" name="submit" value="Reload This Page Now" onClick="window.location.reload()" /></div>';
     50    die();
     51}
     52
     53
     54/**
     55 * Delete the attachments of a parent post
     56 *
     57 * @param $pid
     58 */
     59function rssmi_delete_attachment( $pid ) {
     60
     61    $attachments = get_children( array(
     62        'post_type'      => 'attachment',
     63        'posts_per_page' => - 1,
     64        'post_status'    => 'any',
     65        'post_parent'    => $pid
     66    ) );
     67
     68    if ( empty( $attachments ) ) {
     69        return;
     70    }
     71
     72    foreach ( $attachments as $attachment ) {
     73        wp_delete_attachment( $attachment->ID, TRUE );
     74    }
     75}
     76
     77
     78/**
     79 * Timed delete of Auto Posts from import_posts.php
     80 */
     81function rssmi_delete_posts() {
     82
     83    $wp_version = (float) get_bloginfo( 'version' );
     84    $options    = get_option( 'rss_post_options' );
     85
     86    // If no expiration is set or auto delete is not on, do nothing
     87    if ( empty( $options['expiration'] ) || empty( $options['autoDelete'] ) ) {
     88        return;
     89    }
     90
     91    // Expiration, in days
     92    $expiration = intval( $options['expiration'] );
     93
     94    // If no status is present, set to Trash (not permanently delete)
     95    $set_post_status = isset( $options['oldPostStatus'] ) ? intval( $options['oldPostStatus'] ) : 1;
     96
     97    // Keep posts with comments
     98    $keep_commented = empty( $options['keepcomments'] ) ? FALSE : TRUE;
     99
     100    // Default arguments
     101    $delete_posts_args = array(
     102        'post_type'      => 'post',
     103        'post_status'    => array( 'publish', 'pending', 'draft', 'auto-draft', 'private', 'inherit', 'trash' ),
     104        'meta_key'       => 'rssmi_source_link',
     105        'posts_per_page' => - 1,
     106    );
     107
     108    // Use date_query if we're using a high enough version
     109    if ( $wp_version >= 3.7 ) {
     110        $date_query                            = TRUE;
     111        $delete_posts_args['suppress_filters'] = TRUE;
     112        $delete_posts_args['date_query']       = array(
     113            'before' => $expiration . ' days ago'
     114        );
     115    }
     116    // Otherwise, need to filter the WHERE clause
     117    else {
     118        $date_query                            = FALSE;
     119        $delete_posts_args['suppress_filters'] = FALSE;
     120        add_filter( 'posts_where', 'rssmi_delete_posts_filter_posts_where', 10 );
     121    }
     122
     123    $delete_posts = get_posts( $delete_posts_args );
     124
     125    // Remove the filter, if added
     126    if ( ! $date_query ) {
     127        remove_filter( 'posts_where', 'rssmi_delete_posts_filter_posts_where', 10 );
     128    }
     129
     130    // No posts? Nothing to do...
     131    if ( empty( $delete_posts ) ) {
     132        return;
     133    }
     134
     135    foreach ( $delete_posts as $delete_me ) {
     136
     137        $pid = $delete_me->ID;
     138
     139        // Protected post, skip
     140        // TODO: Add this as a meta_query if version >= 3.5
     141        if ( get_post_meta( $pid, 'rssmi_source_protect', TRUE ) ) {
     142            continue;
    116143        }
    117     }
    118 }
    119 
    120 
    121 function rssmi_delete_posts(){  //TIMED DELETE OF AUTOPOSTS - FROM IMPORT_POSTS.PHP
    122    
    123     global $wpdb;
    124     $post_options_delete = get_option('rss_post_options');
    125     $expiration=$post_options_delete['expiration'];
    126     $oldPostStatus=$post_options_delete['oldPostStatus'];
    127     $keepcomments= $post_options_delete['keepcomments'];
    128     $serverTimezone=$post_options_delete['timezone'];
    129    
    130     if (isset($serverTimezone) && $serverTimezone!=''){
    131         date_default_timezone_set($serverTimezone);
    132     }
    133    
    134 
    135     $query = "SELECT ID FROM $wpdb->posts WHERE post_status = 'publish' AND post_type = 'post' AND DATEDIFF(NOW(), `post_date`) > ".$expiration;
    136     $ids = $wpdb->get_results($query);
    137    
    138 
    139    
    140     foreach ($ids as $id){
    141         $mypostids = $wpdb->get_results("SELECT * FROM $wpdb->postmeta WHERE meta_key = 'rssmi_source_link' AND post_id = ".$id->ID);
    142        
    143    
    144         if(get_post_meta($id->ID, 'rssmi_source_protect', true)==1) continue;
    145         if (!empty($mypostids)){
    146        
    147            
    148             if ($keepcomments==1 && get_comments_number($id->ID)==0){
    149                 $okToDelete=1;
    150             }elseif ($keepcomments==1 && get_comments_number($id->ID)>0){
    151                 add_post_meta($id->ID, 'rssmi_source_protect', 1);
    152                 $okToDelete=0;
    153             }elseif ($keepcomments!=1){
    154                 $okToDelete=1;
    155             }
    156            
    157            
    158            
    159             if($oldPostStatus==0  && $okToDelete==1){
    160                    
    161                 rssmi_delete_attachment($id->ID);
    162                 wp_delete_post($id->ID, true);
    163 
    164             }elseif ($oldPostStatus==1){
    165                 wp_delete_post($id->ID, false);
    166             }elseif($oldPostStatus==2){
    167                 rssmi_change_post_status($id->ID,'pending');
    168             }
    169        
     144
     145        // If the post has comments and $keep_commented is true, skip
     146        if ( $keep_commented && get_comments_number( $pid ) ) {
     147            add_post_meta( $pid, 'rssmi_source_protect', 1 );
     148            continue;
    170149        }
    171150
    172     }
    173    
    174 }
    175 
    176 
    177 
    178 function rssmi_delete_custom_posts(){  // TIMED DELETE ITEMS USED FOR FEED ITEMS
    179    
    180     global $wpdb;
    181     $custom_post_options_delete = get_option( 'rssmi_global_options' );
    182     $post_options = get_option('rss_post_options');
    183     $expiration=$custom_post_options_delete['expiration'];
    184     $serverTimezone=$post_options['timezone'];
    185 
    186 
    187         if (isset($serverTimezone) && $serverTimezone!=''){
    188             date_default_timezone_set($serverTimezone);
     151        // Set status or delete, depending on settings
     152        switch ( $set_post_status ) {
     153
     154            // Delete permanently
     155            case 0:
     156                rssmi_delete_attachment( $pid );
     157                wp_delete_post( $pid, TRUE );
     158                break;
     159
     160            // Move to trash
     161            case 1:
     162                wp_delete_post( $pid, FALSE );
     163                break;
     164
     165            // Change to pending
     166            case 2:
     167                wp_update_post( array(
     168                    'ID'          => $pid,
     169                    'post_status' => 'pending'
     170                ) );
     171                break;
    189172        }
    190        
    191     if (isset($expiration) && $expiration!=0){
    192 
    193         $query = "SELECT ID FROM $wpdb->posts WHERE post_status = 'publish' AND post_type = 'rssmi_feed_item' AND DATEDIFF(NOW(), `post_date`) > ".$expiration;
    194        
    195    
    196 
    197     $ids = $wpdb->get_results($query);
    198 //  var_dump($ids);
    199 //  exit;
    200    
    201    
    202         if (!empty($ids)){
    203             foreach ($ids as $id){
    204                     wp_delete_post($id->ID, true);
    205                 }
    206 
    207         }
    208     }
    209 }
    210 
    211 
    212 
    213 
    214 function rssmi_delete_all_custom_posts(){  // DELETE ALL FEED ITEMS
    215    
    216     global $wpdb;
    217            
    218    
    219     $query = "SELECT ID FROM $wpdb->posts WHERE post_status = 'publish' AND post_type = 'rssmi_feed_item'";
    220    
    221 
    222    
    223    
    224     $ids = $wpdb->get_results($query);
    225         if (!empty($ids)){
    226             foreach ($ids as $id){
    227                     wp_delete_post($id->ID, true);
    228                 }
    229 
    230             }
    231 
    232 }
    233 
    234 
    235 
    236 
    237 
    238 function rssmi_delete_autoposts(){  //  USE FOR QUICK DELETE OF BLOG POSTS ONLY
    239    
    240     global $wpdb;
    241 
    242     $query = "SELECT ID FROM $wpdb->posts WHERE post_status = 'publish' AND post_type != 'rssmi_feed'";
    243 
    244     $ids = $wpdb->get_results($query);
    245    
    246     foreach ($ids as $id){
    247 
    248     $mypostids = $wpdb->get_results("SELECT * FROM $wpdb->postmeta WHERE  meta_key = 'rssmi_source_link' AND post_id = ".$id->ID);
    249    
    250         if (!empty($mypostids)){
    251             rssmi_delete_attachment($id->ID);
    252                 wp_delete_post($id->ID, true);
    253         }
    254     }
    255    
    256 }
    257 
    258 
    259 
    260 add_action('delete_post', 'rssmi_on_delete');
    261 
    262 function rssmi_on_delete($post_id) {
    263     $post = get_post($post_id);
    264     if ($post->post_type == 'rssmi_feed') {
    265         rssmi_delete_all_for_feed($post_id);
    266         rssmi_delete_all_posts_for_feed($post_id);
    267        }
    268 }
    269 
    270 
    271 
    272 
    273 function rssmi_delete_all_for_feed($id){   //  THIS DELETES FEED ITEMS FOR A SPECIFIC FEED ID
    274 
    275     global $wpdb;
    276 
    277     $myquery = "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = 'rssmi_item_feed_id' AND meta_value = ".$id;   
    278 //  echo $myquery;
    279    
    280     $myids = $wpdb->get_results($myquery);
    281    
    282     if (!empty($myids)){
    283        
    284         foreach ($myids as $id){
    285             delete_post_meta($id->post_id, "rssmi_item_date");
    286             delete_post_meta($id->post_id, "rssmi_item_description");
    287             delete_post_meta($id->post_id, "rssmi_item_feed_id");
    288             delete_post_meta($id->post_id, "rssmi_item_permalink");
    289             rssmi_delete_attachment($id->post_id);
    290             wp_delete_post($id->post_id, true);
    291         }
    292            
    293     }
    294    
    295 }
    296 
    297 
    298 
    299 function rssmi_delete_all_posts_for_feed($id){  //  THIS DELETES AUTOPOSTS FOR A SPECIFIC FEED ID
    300    
    301     global $wpdb;
    302 
    303     $query = "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = 'rssmi_source_feed' and meta_value = ".$id;
    304    
    305     $mypostids = $wpdb->get_results($query);
    306    
    307         if (!empty($mypostids)){
    308             foreach ($mypostids as $mypostid){
    309             rssmi_delete_attachment($mypostid->post_id);
    310                 wp_delete_post($mypostid->post_id, true);
    311             }
    312         }
    313        
    314 }
    315 
    316 
    317 
    318 
    319 
    320 function rssmi_delete_posts_admin(){  //  USE FOR QUICK DELETE OF ALL AUTOPOSTS
    321    
     173    }
     174}
     175
     176/**
     177 * Filter for expiration data added to SQL query
     178 *
     179 * @param $where
     180 *
     181 * @return string
     182 */
     183function rssmi_delete_posts_filter_posts_where( $where ) {
     184
     185    $options = get_option( 'rss_post_options' );
     186
     187    // If no expiration is set, do nothing
     188    if ( ! empty( $options['expiration'] ) ) {
     189        $expiration = intval( $options['expiration'] );
     190        $where .= " AND post_date < '" . date( 'Y-m-d H:i:s', strtotime( '-' . $expiration . ' days' ) ) . "'";
     191    }
     192
     193    return $where;
     194}
     195
     196
     197/**
     198 * Timed delete for RSS Feed Items
     199 */
     200function rssmi_delete_custom_posts() {
     201
     202    $wp_version = (float) get_bloginfo( 'version' );
     203    $options = get_option( 'rssmi_global_options' );
     204
     205    // Expiration not set or set to "0" (never delete)
     206    if ( empty( $options['expiration'] ) ) {
     207        return;
     208    }
     209    $expiration = intval( $options['expiration'] );
     210
     211    // Default arguments
     212    $delete_posts_args = array(
     213        'post_type'      => 'rssmi_feed_item',
     214        'posts_per_page' => - 1,
     215        'post_status'    => array( 'publish', 'pending', 'draft', 'auto-draft', 'private', 'inherit', 'trash' ),
     216    );
     217
     218    // Use date_query if we're using a high enough version
     219    if ( $wp_version >= 3.7 ) {
     220        $date_query                            = TRUE;
     221        $delete_posts_args['suppress_filters'] = TRUE;
     222        $delete_posts_args['date_query']       = array(
     223            'before' => $expiration . ' days ago'
     224        );
     225    }
     226    // Otherwise, need to filter the WHERE clause
     227    else {
     228        $date_query                            = FALSE;
     229        $delete_posts_args['suppress_filters'] = FALSE;
     230        add_filter( 'posts_where', 'rssmi_delete_custom_posts_filter_posts_where', 10 );
     231    }
     232
     233    $delete_items = get_posts( $delete_posts_args );
     234
     235    // Remove the filter, if added
     236    if ( ! $date_query ) {
     237        remove_filter( 'posts_where', 'rssmi_delete_custom_posts_filter_posts_where', 10 );
     238    }
     239
     240    foreach ( $delete_items as $delete_me ) {
     241        wp_delete_post( $delete_me->ID, TRUE );
     242    }
     243}
     244
     245
     246/**
     247 * Filter for expiration data added to SQL query
     248 *
     249 * @param $where
     250 *
     251 * @return string
     252 */
     253function rssmi_delete_custom_posts_filter_posts_where( $where ) {
     254
     255    $options = get_option( 'rssmi_global_options' );
     256
     257    // If no expiration is set, do nothing
     258    if ( ! empty( $options['expiration'] ) ) {
     259        $expiration = intval( $options['expiration'] );
     260        $where .= " AND post_date < '" . date( 'Y-m-d', strtotime( '-' . $expiration . ' days' ) ) . "'";
     261    }
     262
     263    return $where;
     264}
     265
     266
     267/**
     268 * Delete all feed items
     269 */
     270function rssmi_delete_all_custom_posts() {
     271
     272    $delete_posts_args = array(
     273        'post_type'      => 'rssmi_feed_item',
     274        'posts_per_page' => - 1,
     275        'post_status'    => array( 'publish', 'pending', 'draft', 'auto-draft', 'private', 'inherit', 'trash' ),
     276    );
     277
     278    $delete_posts = get_posts( $delete_posts_args );
     279
     280    if ( empty( $delete_posts ) ) {
     281        return;
     282    }
     283
     284    foreach ( $delete_posts as $delete_me ) {
     285        wp_delete_post( $delete_me->ID, TRUE );
     286    }
     287}
     288
     289
     290/**
     291 * Deletes all auto-posts
     292 */
     293function rssmi_delete_autoposts() {
     294
     295    $options = get_option( 'rss_post_options' );
     296
     297    // Type of autoposts to delete
     298    $post_type = 'post';
     299    if ( ! empty( $options['custom_type_name'] ) ) {
     300        $post_type = sanitize_text_field( $options['custom_type_name'] );
     301    }
     302
     303    $delete_posts_args = array(
     304        'post_type'      => $post_type,
     305        'posts_per_page' => - 1,
     306        'post_status'    => array( 'publish', 'pending', 'draft', 'auto-draft', 'private', 'inherit', 'trash' ),
     307        'meta_key' => 'rssmi_source_link',
     308    );
     309
     310    $delete_posts = get_posts( $delete_posts_args );
     311
     312    if ( empty( $delete_posts ) ) {
     313        return;
     314    }
     315
     316    foreach ( $delete_posts as $delete_me ) {
     317        $pid = $delete_me->ID;
     318        rssmi_delete_attachment( $pid );
     319        wp_delete_post( $pid, TRUE );
     320    }
     321}
     322
     323
     324/**
     325 * Hook function to delete all associated items and auto-posts for a certain feed
     326 *
     327 * @param $pid
     328 */
     329function rssmi_on_delete( $pid ) {
     330    $post = get_post( $pid );
     331    if ( 'rssmi_feed' === $post->post_type ) {
     332        rssmi_delete_all_for_feed( $pid );
     333        rssmi_delete_all_posts_for_feed( $pid );
     334    }
     335}
     336
     337add_action( 'delete_post', 'rssmi_on_delete' );
     338
     339/**
     340 * Delete all feed items for a specific feed
     341 *
     342 * @param $pid
     343 */
     344function rssmi_delete_all_for_feed( $pid ) {
     345
     346    $delete_posts_args = array(
     347        'post_type'      => 'rssmi_feed_item',
     348        'posts_per_page' => - 1,
     349        'post_status'    => array( 'publish', 'pending', 'draft', 'auto-draft', 'private', 'inherit', 'trash' ),
     350        'meta_query'     => array(
     351            array(
     352                'key'   => 'rssmi_item_feed_id',
     353                'value' => $pid
     354            )
     355        )
     356    );
     357
     358    $delete_posts = get_posts( $delete_posts_args );
     359
     360    if ( empty( $delete_posts ) ) {
     361        return;
     362    }
     363
     364    foreach ( $delete_posts as $delete_me ) {
     365        $pid = $delete_me->ID;
     366        rssmi_delete_attachment( $pid );
     367        wp_delete_post( $pid, TRUE );
     368    }
     369
     370}
     371
     372
     373/**
     374 * Delete all auto-posts for a specific feed
     375 *
     376 * @param $pid
     377 */
     378function rssmi_delete_all_posts_for_feed( $pid ) {
     379
     380    $options = get_option( 'rss_post_options' );
     381
     382    // Type of autoposts to delete
     383    $post_type = 'post';
     384    if ( ! empty( $options['custom_type_name'] ) ) {
     385        $post_type = sanitize_text_field( $options['custom_type_name'] );
     386    }
     387
     388    $delete_posts_args = array(
     389        'post_type'      => $post_type,
     390        'posts_per_page' => - 1,
     391        'post_status'    => array( 'publish', 'pending', 'draft', 'auto-draft', 'private', 'inherit', 'trash' ),
     392        'meta_query'     => array(
     393            array(
     394                'key'   => 'rssmi_source_feed',
     395                'value' => $pid
     396            )
     397        )
     398    );
     399
     400    $delete_posts = get_posts( $delete_posts_args );
     401
     402    if ( empty( $delete_posts ) ) {
     403        return;
     404    }
     405
     406    foreach ( $delete_posts as $delete_me ) {
     407        $pid = $delete_me->ID;
     408        rssmi_delete_attachment( $pid );
     409        wp_delete_post( $pid, TRUE );
     410    }
     411
     412}
     413
     414
     415/**
     416 * Deletes all content created by this plugin
     417 */
     418function rssmi_restore_all() {
     419
     420    rssmi_delete_autoposts();
     421
     422    $delete_posts_args = array(
     423        'post_type'      => array( 'rssmi_feed_item', 'rssmi_feed' ),
     424        'posts_per_page' => -1,
     425        'post_status'    => array( 'publish', 'pending', 'draft', 'auto-draft', 'private', 'inherit', 'trash' ),
     426    );
     427
     428    $delete_posts = get_posts( $delete_posts_args );
     429
     430    if ( empty( $delete_posts ) ) {
     431        return;
     432    }
     433
     434    foreach ( $delete_posts as $delete_me ) {
     435        $pid = $delete_me->ID;
     436        rssmi_delete_attachment( $pid );
     437        wp_delete_post( $pid, TRUE );
     438    }
     439
     440}
     441
     442/*
     443 * DEPRECATED
     444 */
     445
     446// TODO: Deprecate me, changed rssmi_delete_attachment() to process in-line
     447function rssmi_change_post_status( $post_id, $status ) {
     448
     449    trigger_error( "Deprecated function called: " . __FUNCTION__, E_USER_NOTICE );
     450
     451    $current_post                = get_post( $post_id, 'ARRAY_A' );
     452    $current_post['post_status'] = $status;
     453    wp_update_post( $current_post );
     454}
     455
     456// TODO: Deprecate me, replaced with rssmi_delete_autoposts()
     457function rssmi_delete_posts_admin() {
     458
     459    trigger_error( "Deprecated function called: " . __FUNCTION__, E_USER_NOTICE );
     460
    322461    global $wpdb;
    323462    $query = "SELECT * FROM $wpdb->postmeta WHERE meta_key = 'rssmi_source_link'";
    324     $ids = $wpdb->get_results($query);
    325 
    326         if (!empty($ids)){
    327                 foreach ($ids as $id){
    328                     rssmi_delete_attachment($id->ID);
    329                     wp_delete_post($id->ID, true);
    330                 }
    331             }
    332    
    333 
    334 }
    335 
    336 
    337 
    338 
    339 
    340 
    341 
    342 
    343 
    344 function rssmi_restore_all(){  //  DELETES EVERYTHING CAUSED BY THIS PLUGIN IN THE POST AND POST META TABLES
    345     global $wpdb;   
    346     rssmi_delete_posts_admin();
    347 
    348     $query = "SELECT ID FROM $wpdb->posts WHERE post_status = 'publish' AND (post_type = 'rssmi_feed_item' OR post_type = 'rssmi_feed')";
    349 
    350     $ids = $wpdb->get_results($query);
    351 
    352     if (!empty($ids)){
    353         foreach ($ids as $id){
    354             rssmi_delete_attachment($id->ID);
    355             wp_delete_post($id->ID, true);
    356             }
    357 
     463    $ids   = $wpdb->get_results( $query );
     464
     465    if ( ! empty( $ids ) ) {
     466        foreach ( $ids as $id ) {
     467            rssmi_delete_attachment( $id->ID );
     468            wp_delete_post( $id->ID, true );
    358469        }
    359    
    360 }
    361 
    362 
    363 
    364 function rssmi_delete_widow_links(){
    365 global $wpdb;   
    366    
    367     $query='SELECT post_id from $wpdb->postmeta where (meta_key="rssmi_item_permalink" OR meta_key="rssmi_source_link")';
    368    
    369     $ids = $wpdb->get_results($query);
    370    
    371         foreach ($ids as $id){
    372            
    373             $mypostids = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE ID = ".$id->ID);
    374            
    375                 if (empty($mypostids)){
    376                     delete_post_meta($id->ID, "rssmi_item_date");
    377                     delete_post_meta($id->ID, "rssmi_item_description");
    378                     delete_post_meta($id->ID, "rssmi_item_feed_id");
    379                     delete_post_meta($id->ID, "rssmi_item_permalink");
    380                     delete_post_meta($id->ID, "rssmi_source_link");
    381                     delete_post_meta($id->ID, "rssmi_source_feed");
    382                    
    383                 }
    384             }
    385    
    386 }
    387 
    388 
    389 
    390 ?>
     470    }
     471}
     472
     473// TODO: Deprecate me, these transients are not being set
     474function delete_db_transients() {
     475
     476    trigger_error( "Deprecated function called: " . __FUNCTION__, E_USER_NOTICE );
     477
     478    global $wpdb;
     479    $expired = $wpdb->get_col( "
     480        SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE '_transient_wprssmi_%';
     481    " );
     482
     483    foreach ( $expired as $transient ) {
     484        $key = str_replace( '_transient_', '', $transient );
     485        delete_transient( $key );
     486    }
     487}
     488
     489// TODO: Deprecate me, unused
     490function rssmi_list_the_plugins() {
     491
     492    trigger_error( "Deprecated function called: " . __FUNCTION__, E_USER_NOTICE );
     493
     494    $plugins = get_option( 'active_plugins', array() );
     495    foreach ( $plugins as $plugin ) {
     496        echo "<li>$plugin</li>";
     497    }
     498}
     499
     500// TODO: Deprecate me, unused
     501function rssmi_list_options() {
     502
     503    trigger_error( "Deprecated function called: " . __FUNCTION__, E_USER_NOTICE );
     504
     505    $options = get_option( 'rss_import_options' );
     506
     507    foreach ( $options as $option ) {
     508        echo "<li>$option</li>";
     509    }
     510
     511}
     512
     513// TODO: Deprecate me, unused
     514function rssmi_delete_posts_admin_attachment( $pid ) {
     515
     516    trigger_error( "Deprecated function called: " . __FUNCTION__, E_USER_NOTICE );
     517
     518    $rssmi_source_link = get_post_meta( $pid, 'rssmi_source_link', true );
     519    if ( ! empty( $rssmi_source_link ) ) {
     520        rssmi_delete_attachment( $rssmi_source_link );
     521    }
     522}
     523
     524// TODO: Deprecate me, unused
     525function rssmi_delete_widow_links() {
     526
     527    trigger_error( "Deprecated function called: " . __FUNCTION__, E_USER_NOTICE );
     528
     529    global $wpdb;
     530
     531    $query = 'SELECT post_id from $wpdb->postmeta where (meta_key="rssmi_item_permalink" OR meta_key="rssmi_source_link")';
     532
     533    $ids = $wpdb->get_results( $query );
     534
     535    foreach ( $ids as $id ) {
     536
     537        $mypostids = $wpdb->get_results( "SELECT * FROM $wpdb->posts WHERE ID = " . $id->ID );
     538
     539        if ( empty( $mypostids ) ) {
     540            delete_post_meta( $id->ID, "rssmi_item_date" );
     541            delete_post_meta( $id->ID, "rssmi_item_description" );
     542            delete_post_meta( $id->ID, "rssmi_item_feed_id" );
     543            delete_post_meta( $id->ID, "rssmi_item_permalink" );
     544            delete_post_meta( $id->ID, "rssmi_source_link" );
     545            delete_post_meta( $id->ID, "rssmi_source_feed" );
     546
     547        }
     548    }
     549}
  • wp-rss-multi-importer/trunk/inc/export.php

    r964637 r989112  
    2727
    2828
    29 <h2><?php _e("Export Your Feeds as an RSS Feed", 'wp-rss-multi-importer')?></h3>
     29<h2><?php _e("Export Your Feeds as an RSS Feed", 'wp-rss-multi-importer')?></h2>
    3030<h3><?php _e("Export Feed Options Settings", 'wp-rss-multi-importer')?></h3>
    3131<p><?php _e("You can re-export your feeds as an RSS feed for your readers.  You configure some options for this feed here.", 'wp-rss-multi-importer')?></p>
  • wp-rss-multi-importer/trunk/inc/global_settings.php

    r976190 r989112  
    144144   
    145145   
    146 <!--
     146
    147147    <p ><label class='o_textinput' for='item_freshness'><?php _e("Only bring in items newer than how many days old?", 'wp-rss-multi-importer')?></label>
    148148 <input  id='item_freshness' type="text" size='8'  Name="rssmi_global_options[item_freshness]" Value="<?php echo $rssmi_global_options['item_freshness'] ?>">days old (leave blank to place no restriction.)
    149149    </p>
    150 -->
     150
    151151   
    152152   
  • wp-rss-multi-importer/trunk/inc/import_feeds.php

    r976190 r989112  
    8484                               
    8585                            }
    86                            
     86
    8787                        if (rssmi_is_not_fresh($post_date)==1){continue;}  //filter for days old
    8888                       
  • wp-rss-multi-importer/trunk/inc/import_posts.php

    r976190 r989112  
    667667
    668668//Add main content
    669    
    670     $thisExcerpt = showexcerpt($items["mydesc"],$descNum,$openWindow,$stripAll,$items["mylink"],$adjustImageSize,$float,$noFollow,$items["myimage"],$items["mycatid"],$stripSome,$useMediaImage);
     669
     670    $thisExcerpt = showexcerpt($items["mydesc"],$descNum,$openWindow,$stripAll,$items["mylink"],$adjustImageSize,$float,$noFollow,$items["myimage"],$items["mycatid"],$stripSome,$feedHomePage, $noProcess,$useMediaImage);
     671   
     672
    671673   
    672674//  Add video if exists
     
    715717   
    716718    if ($showsocial==1){
    717     $thisContent .= '<span style="margin-left:10px;"><a href="http://www.facebook.com/sharer/sharer.php?u='.$items["mylink"].'"><img src="'.WP_RSS_MULTI_IMAGES.'facebook.png"/></a>&nbsp;&nbsp;<a href="http://twitter.com/intent/tweet?text='.rawurlencode($items["mytitle"]).'%20'.$items["mylink"].'"><img src="'.WP_RSS_MULTI_IMAGES.'twitter.png"/></a>&nbsp;&nbsp;<a href="http://plus.google.com/share?url='.rawurlencode($items["mylink"]).'"><img src="'.WP_RSS_MULTI_IMAGES.'gplus.png"/></a></span>';
     719    $thisContent .= '<span style="margin-left:10px;"><a href="http://www.facebook.com/sharer/sharer.php?u='.$items["mylink"].'"><img src="'.WP_RSS_MULTI_IMAGES.'facebook.png"/></a>&nbsp;&nbsp;<a href="http://twitter.com/intent/tweet?text='.rawurlencode($items["mytitle"]).'%20'.$items["mylink"].'"><img src="'.WP_RSS_MULTI_IMAGES.'twitter.png"/></a>&nbsp;&nbsp;<a href="http://plus.google.com/share?url='.rawurlencode($items["mylink"]).'"><img src="'.WP_RSS_MULTI_IMAGES.'gplus.png"/></a>&nbsp;&nbsp;<a href="http://www.linkedin.com/shareArticle?mini=true&url='.rawurlencode($items["mylink"]).'"><img src="'.WP_RSS_MULTI_IMAGES.'linkedin.png"/></a></span>';
    718720    }
    719721   
  • wp-rss-multi-importer/trunk/inc/options.php

    r976190 r989112  
    879879<OPTION VALUE="quote" <?php if($post_options['post_format']=="quote"){echo 'selected';} ?>>Quote</OPTION>
    880880<OPTION VALUE="status" <?php if($post_options['post_format']=="status"){echo 'selected';} ?>>Status</OPTION>
     881<OPTION VALUE="video" <?php if($post_options['post_format']=="video"){echo 'selected';} ?>>Video</OPTION>
    881882</SELECT></p>
    882883
     
    10961097<h3><?php _e("Auto Remove Posts", 'wp-rss-multi-importer')?></h3>
    10971098
    1098 <p ><label class='o_textinput' for='autoDelete'><?php _e("Check to Auto Remove Posts Created by this Plugin", 'wp-rss-multi-importer')?>   <input type="checkbox" id="autoRemoveCB" Name="rss_post_options[autoDelete]" Value="1" <?php if (isset($post_options['autoDelete']) && $post_options['autoDelete']==1){echo 'checked="checked"';} ?>></label>   (<a href="/wp-admin/options-general.php?page=wp_rss_multi_importer_admin&tab=posts_list">Manage what posts to keep here.</a>)</p>
     1099<p ><label class='o_textinput' for='autoDelete'><?php _e("Check to Auto Remove Posts Created by this Plugin", 'wp-rss-multi-importer')?>   <input type="checkbox" id="autoRemoveCB" Name="rss_post_options[autoDelete]" Value="1" <?php if (isset($post_options['autoDelete']) && $post_options['autoDelete']==1){echo 'checked="checked"';} ?>></label>   (<a href="/wp-admin/admin.php?page=wprssmi_options3&tab=manage_autoposts">Manage what posts to keep here.</a>)</p>
    10991100
    11001101<span id="autoremoveposts" <?php if(isset($post_options['autoDelete']) && $post_options['autoDelete']!=1){echo 'style="display:none"';}?>>
  • wp-rss-multi-importer/trunk/inc/rss_multi_importer_widget.php

    r976190 r989112  
    8585        $showdesc = $instance['showdesc'];
    8686        $maxposts = $instance['maxposts'];
    87         $targetWindow= $instance['targetwindow'];
     87        $targetwindow= $instance['targetwindow'];
    8888        $simplelist= $instance['simplelist'];
    8989        $showimage= $instance['showimage'];
     
    101101        global $isMobileDevice;
    102102        if (isset($isMobileDevice) && $isMobileDevice==1){  //open mobile device windows in new tab
    103             $targetWindow=2;
     103            $targetwindow=2;
    104104
    105105            }
     
    143143        $options = get_option('rss_import_items','option not found');
    144144        if (!empty($options)) {
    145             $targetWindow=(isset($options['targetWindow']) ? $options['targetWindow'] : null);
     145        //  $targetwindow=(isset($options['targetWindow']) ? $options['targetWindow'] : null);
    146146        }else{
    147             $targetWindow=2;   
    148         }
    149        
    150    
     147        //  $targetwindow=2;   
     148        }
     149       
     150
    151151
    152152        global $wpdb;
     
    185185           
    186186               
    187         $rssmi_sql = "SELECT a.post_id,b.meta_key,b.meta_value FROM $wpdb->postmeta as a inner join $wpdb->postmeta as b on a.post_id=b.post_id WHERE a.meta_value =$feed->ID and b.meta_key='rssmi_item_date' order by b.meta_value desc";
     187   
     188            $rssmi_sql = "SELECT a.post_id,b.meta_key,b.meta_value FROM $wpdb->postmeta as a inner join $wpdb->postmeta as b on a.post_id=b.post_id WHERE a.meta_value =$feed->ID and b.meta_key='rssmi_item_date' order by b.meta_value ";
     189
     190            if ($sortDir==0){
     191                $rssmi_sql .="desc";
     192            }elseif ($sortDir==1){
     193                $rssmi_sql .="asc";
     194            }
     195
     196       
     197       
     198       
     199       
    188200                $desc_array = $wpdb->get_results($rssmi_sql);           
    189201               
     
    220232        global $isMobileDevice;
    221233        if (isset($isMobileDevice) && $isMobileDevice==1){  //open mobile device windows in new tab
    222             $targetWindow=2;
     234            $targetwindow=2;
    223235            }
    224236
     
    248260        global $isMobileDevice;
    249261            if (isset($isMobileDevice) && $isMobileDevice==1){  //open mobile device windows in new tab
    250                 $targetWindow=2;
     262            $targetwindow=2;
    251263                }
    252264
    253         if($targetWindow==0){
     265        if($targetwindow==0){
    254266            $openWindow='class="colorbox"';
    255         }elseif ($targetWindow==1){
     267        }elseif ($targetwindow==1){
    256268            $openWindow='target=_self';     
    257269        }else{
     
    276288        foreach($myarray as $items) {
    277289           
     290           
     291           
    278292                // VIDEO CHECK
    279                 if ($targetWindow==0){
     293                if ($targetwindow==0){
    280294                    $getVideoArray=rssmi_video($items["mylink"]);
    281295                    $openWindow=$getVideoArray[1];
    282296                    $items["mylink"]=$getVideoArray[0];
    283297                }
    284         $openWindow=rssmi_lightbox_filter($items["mylink"],$targetWindow); //Lightbox filter
     298               
     299               
     300        $openWindow=rssmi_lightbox_filter($items["mylink"],$targetwindow); //Lightbox filter
     301       
     302   
    285303        $total = $total +1;
    286304           
     
    315333
    316334                // VIDEO CHECK
    317                 if ($targetwindow==0){
     335                if ($targetWindow==0){
    318336                    $getVideoArray=rssmi_video($items["mylink"],$targetwindow);
    319337                    $openWindow=$getVideoArray[1];
     
    328346
    329347            echo '<div style="top: 101px;margin-left:5px;" class="news">';
    330         //  echo '<p class="widget-rss-output" style="margin-right:5px">';
     348
    331349           
    332350           
  • wp-rss-multi-importer/trunk/inc/scripts.php

    r964637 r989112  
    44
    55
    6 function rssmi_is_plugin_page(){
     6function rssmi_is_plugin_page() {
    77    $screen = get_current_screen();
    8     if ((isset( $_GET['post_type'] )) && (strpos($_GET['post_type'],'rssmi_feed' ,0)!==false) || ( isset( $_GET['page'] )) && ((strpos($_GET['page'],'wprssmi',0)!==false) || (strpos($_GET['page'],'wprssmi',0 )!==false ) || (strpos($_GET['page'],'wprssmi_options',0 )!==false ) || (strpos($_GET['page'],'wprssmi_options2',0 )!==false ) || (strpos($_GET['page'],'wprssmi_options3',0 )!==false ) || (strpos($_GET['page'],'wprssmi_options4',0 )!==false ) || (strpos($_GET['page'],'wprssmi_options9', 0)!==false )  || (isset( $_GET['post_type'] )) && (strpos($_GET['post_type'],'rssmi_feed_item', 0)!==false)  || (strpos($_GET['page'],'wprssmi_options5',0 )!==false ) || (strpos($_GET['page'],'wprssmi_options8',0 )!==false )|| (strpos($_GET['page'],'wprssmi_options7',0 )!==false ))) {
    9         $msg=1;
    10     }else{
    11         $msg=0;
    12     }
    13      
     8    if ( ( isset( $_GET['post_type'] ) ) && ( strpos( $_GET['post_type'], 'rssmi_feed', 0 ) !== false ) || ( isset( $_GET['page'] ) ) && ( ( strpos( $_GET['page'], 'wprssmi', 0 ) !== false ) || ( strpos( $_GET['page'], 'wprssmi', 0 ) !== false ) || ( strpos( $_GET['page'], 'wprssmi_options', 0 ) !== false ) || ( strpos( $_GET['page'], 'wprssmi_options2', 0 ) !== false ) || ( strpos( $_GET['page'], 'wprssmi_options3', 0 ) !== false ) || ( strpos( $_GET['page'], 'wprssmi_options4', 0 ) !== false ) || ( strpos( $_GET['page'], 'wprssmi_options9', 0 ) !== false ) || ( isset( $_GET['post_type'] ) ) && ( strpos( $_GET['post_type'], 'rssmi_feed_item', 0 ) !== false ) || ( strpos( $_GET['page'], 'wprssmi_options5', 0 ) !== false ) || ( strpos( $_GET['page'], 'wprssmi_options8', 0 ) !== false ) || ( strpos( $_GET['page'], 'wprssmi_options7', 0 ) !== false ) ) ) {
     9        $msg = 1;
     10    }
     11    else {
     12        $msg = 0;
     13    }
     14
    1415    return $msg;
    1516}
    1617
    1718
    18 function rssmi_rate_plugin_page(){
    19    
    20         if ((isset( $_GET['post_type'] )) && (strpos($_GET['post_type'] ,'rssmi_feed',0)!==false) || ( isset( $_GET['page'] )) && ((strpos($_GET['page'] ,'wprssmi',0)!==false) || (strpos($_GET['page'],'wprssmi',0)!==false ) || (strpos($_GET['page'] ,'wprssmi_options',0)!==false ) || (strpos($_GET['page'],'wprssmi_options2',0 )!==false ) || (strpos($_GET['page'],'wprssmi_options3', 0)!==false ) || (strpos($_GET['page'], 'wprssmi_options4',0 )!==false ) || (strpos($_GET['page'] , 'wprssmi_options9',0)!==false )  || (strpos($_GET['page'] ,'wprssmi_options5',0)!==false ) || (strpos($_GET['page'],'wprssmi_options8', 0)!==false )|| (strpos($_GET['page'], 'wprssmi_options7', 0)!==false ))) {
    21            
    22                 $msg=1;
    23             }else{
    24                 $msg=0;
    25             }
    26             return $msg;
    27            
    28 }
    29 
    30 
     19function rssmi_rate_plugin_page() {
     20
     21    if ( ( isset( $_GET['post_type'] ) ) && ( strpos( $_GET['post_type'], 'rssmi_feed', 0 ) !== false ) || ( isset( $_GET['page'] ) ) && ( ( strpos( $_GET['page'], 'wprssmi', 0 ) !== false ) || ( strpos( $_GET['page'], 'wprssmi', 0 ) !== false ) || ( strpos( $_GET['page'], 'wprssmi_options', 0 ) !== false ) || ( strpos( $_GET['page'], 'wprssmi_options2', 0 ) !== false ) || ( strpos( $_GET['page'], 'wprssmi_options3', 0 ) !== false ) || ( strpos( $_GET['page'], 'wprssmi_options4', 0 ) !== false ) || ( strpos( $_GET['page'], 'wprssmi_options9', 0 ) !== false ) || ( strpos( $_GET['page'], 'wprssmi_options5', 0 ) !== false ) || ( strpos( $_GET['page'], 'wprssmi_options8', 0 ) !== false ) || ( strpos( $_GET['page'], 'wprssmi_options7', 0 ) !== false ) ) ) {
     22
     23        $msg = 1;
     24    }
     25    else {
     26        $msg = 0;
     27    }
     28    return $msg;
     29
     30}
    3131
    3232
    3333// Only load scripts and CSS if we are on this plugin's options page (admin)
    34 (isset($_GET['post'])?$tp=$_GET['post']:$tp=null);
    35 $cthisPost=get_post($tp, ARRAY_A);
    36 $cType= isset($_GET['post_type'])?$_GET['post_type']:$cthisPost['post_type'];
    37 if (isset($cType) && $cType=='rssmi_feed'){$isCustomEdit=1;}else{$isCustomEdit=0;}
    38 
    39 
    40    
    41     if ($isCustomEdit==1 || (isset( $_GET['post_type'] )) && (strpos($_GET['post_type'] ,'rssmi_feed',0)!==false) || ( isset( $_GET['page'] )) && ((strpos($_GET['page'] ,'wprssmi',0)!==false) || (strpos($_GET['page'], 'wprssmi',0 )!==false ) || (strpos($_GET['page'] ,'wprssmi_options',0)!==false ) || (strpos($_GET['page'] ,'wprssmi_options2',0)!==false ) || (strpos($_GET['page'],'wprssmi_options3',0 )!==false ) || (strpos($_GET['page'], 'wprssmi_options4',0 )!==false ) || (strpos($_GET['page'],'wprssmi_options9',0 )!==false )  || (isset( $_GET['post_type'] )) && (strpos($_GET['post_type'] ,'rssmi_feed_item',0)!==false)  || (strpos($_GET['page'],'wprssmi_options5',0 )!==false ) || (strpos($_GET['page'] ,'wprssmi_options8',0)!==false )|| (strpos($_GET['page'],'wprssmi_options7', 0)!==false ))) {
    42 
    43     add_action( 'init', 'wprssmi_register_scripts' );
    44 
    45     add_action( 'admin_print_styles', 'wprssmi_header' );
    46 
    47     add_action('wp_print_scripts', 'wprssmi_ajax_load_scripts');
    48 
    49 
    50 }
    51 
    52 function rssmi_noindex_function()
    53 {
     34( isset( $_GET['post'] ) ? $tp = $_GET['post'] : $tp = null );
     35$cthisPost = get_post( $tp, ARRAY_A );
     36$cType     = isset( $_GET['post_type'] ) ? $_GET['post_type'] : $cthisPost['post_type'];
     37if ( isset( $cType ) && $cType == 'rssmi_feed' ) {
     38    $isCustomEdit = 1;
     39}
     40else {
     41    $isCustomEdit = 0;
     42}
     43
     44
     45// TODO: needs to be refactored to include properly
     46if ( $isCustomEdit == 1 || ( isset( $_GET['post_type'] ) ) && ( strpos( $_GET['post_type'], 'rssmi_feed', 0 ) !== false ) || ( isset( $_GET['page'] ) ) && ( ( strpos( $_GET['page'], 'wprssmi', 0 ) !== false ) || ( strpos( $_GET['page'], 'wprssmi', 0 ) !== false ) || ( strpos( $_GET['page'], 'wprssmi_options', 0 ) !== false ) || ( strpos( $_GET['page'], 'wprssmi_options2', 0 ) !== false ) || ( strpos( $_GET['page'], 'wprssmi_options3', 0 ) !== false ) || ( strpos( $_GET['page'], 'wprssmi_options4', 0 ) !== false ) || ( strpos( $_GET['page'], 'wprssmi_options9', 0 ) !== false ) || ( isset( $_GET['post_type'] ) ) && ( strpos( $_GET['post_type'], 'rssmi_feed_item', 0 ) !== false ) || ( strpos( $_GET['page'], 'wprssmi_options5', 0 ) !== false ) || ( strpos( $_GET['page'], 'wprssmi_options8', 0 ) !== false ) || ( strpos( $_GET['page'], 'wprssmi_options7', 0 ) !== false ) ) ) {
     47
     48    add_action( 'init', 'wprssmi_register_scripts' );
     49
     50    // TODO: Replace with admin_enqueue_scripts
     51    add_action( 'admin_print_styles', 'wprssmi_header' );
     52
     53    add_action( 'wp_print_scripts', 'wprssmi_ajax_load_scripts' );
     54
     55
     56}
     57
     58function rssmi_noindex_function() {
    5459    global $wp_query;
    55     $postID=$wp_query->post->ID;
    56     $myLink = get_post_meta($postID, 'rssmi_source_link' , true);
    57         if (!empty($myLink) && !is_front_page()  ){
    58 echo '<meta name="robots" content="noindex, nofollow">';
    59 }
    60 }
    61 
    62 
    63 function rssmi_canonical_function(){
    64    
    65         global $wp_query;
    66         $postID=$wp_query->post->ID;
    67         $myLink = get_post_meta($postID, 'rssmi_source_link' , true);
    68             if (!empty($myLink) && !is_front_page()  ){
    69     echo '<link rel="canonical" href="'.$myLink.'"/>';
    70     }           
    71 }
    72 
    73 
    74 function rssmi_pbd_alp_init($max,$paged,$nextPost,$imageURL,$pag) {
    75 
    76     // Add code to index pages.
    77         // Queue JS and CSS
    78         wp_enqueue_script(
    79             'pbd-alp-load-posts',
    80             plugins_url('scripts/load-more.js',
    81             dirname(__FILE__)),
    82             array('jquery'),
    83             '1.0',
    84             true
    85         );
    86 
    87         // Add some parameters for the JS.
    88         wp_localize_script(
    89             'pbd-alp-load-posts',
    90             'pbd_alp',
    91             array(
    92                 'startPage' => $paged,
    93                 'maxPages' => $max,
    94                 'nextLink' => $nextPost,
    95                 'imageURL' => $imageURL,
    96                 'moreMethod'=>$pag
    97             )
    98         );
    99 
    100  }
     60    $postID = $wp_query->post->ID;
     61    $myLink = get_post_meta( $postID, 'rssmi_source_link', true );
     62    if ( ! empty( $myLink ) && ! is_front_page() ) {
     63        echo '<meta name="robots" content="noindex, nofollow">';
     64    }
     65}
     66
     67
     68function rssmi_canonical_function() {
     69
     70    global $wp_query;
     71    $postID = $wp_query->post->ID;
     72    $myLink = get_post_meta( $postID, 'rssmi_source_link', true );
     73    if ( ! empty( $myLink ) && ! is_front_page() ) {
     74        echo '<link rel="canonical" href="' . $myLink . '"/>';
     75    }
     76}
     77
     78
     79function rssmi_pbd_alp_init( $max, $paged, $nextPost, $imageURL, $pag ) {
     80
     81    // Add code to index pages.
     82    // Queue JS and CSS
     83    wp_enqueue_script(
     84        'pbd-alp-load-posts',
     85        plugins_url( 'scripts/load-more.js',
     86            dirname( __FILE__ ) ),
     87        array( 'jquery' ),
     88        '1.0',
     89        true
     90    );
     91
     92    // Add some parameters for the JS.
     93    wp_localize_script(
     94        'pbd-alp-load-posts',
     95        'pbd_alp',
     96        array(
     97            'startPage' => $paged,
     98            'maxPages'  => $max,
     99            'nextLink'  => $nextPost,
     100            'imageURL'  => $imageURL,
     101            'moreMethod' => $pag
     102        )
     103    );
     104
     105}
    101106
    102107/**
    103     * Load scripts for admin, including check for version since new method (.on) used available in jquery 1.7.1
    104     */
     108 * Load scripts for admin, including check for version since new method (.on) used available in jquery 1.7.1
     109 */
    105110
    106111
    107112function wprssmi_register_scripts() {
    108113
    109  global $wp_version;
    110 
    111 if ( version_compare($wp_version, "3.3.1", ">" ) ) { 
    112     wp_enqueue_script( 'jquery' );
    113 } else {   
    114     wp_deregister_script( 'jquery' );
    115     wp_register_script( 'jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js');
    116     wp_enqueue_script( 'jquery' ); 
    117 }
    118   wp_enqueue_script( 'add-remove', plugins_url('scripts/add-remove.js',dirname(__FILE__)),array('jquery'));
    119   wp_localize_script( 'add-remove', 'add_remove_parms', wprssmi_localize_vars());
    120  //wp_enqueue_script( 'bpopup', plugins_url('scripts/jquery.bpopup-0.7.0.min.js',dirname(__FILE__)),array('jquery'));  //adds pop-up ability
    121 
    122 }
    123 
     114    global $wp_version;
     115
     116    if ( version_compare( $wp_version, "3.3.1", ">" ) ) {
     117        wp_enqueue_script( 'jquery' );
     118    }
     119    else {
     120        wp_deregister_script( 'jquery' );
     121        wp_register_script( 'jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js' );
     122        wp_enqueue_script( 'jquery' );
     123    }
     124    wp_enqueue_script( 'add-remove', plugins_url( 'scripts/add-remove.js', dirname( __FILE__ ) ), array( 'jquery' ) );
     125    wp_localize_script( 'add-remove', 'add_remove_parms', wprssmi_localize_vars() );
     126    //wp_enqueue_script( 'bpopup', plugins_url('scripts/jquery.bpopup-0.7.0.min.js',dirname(__FILE__)),array('jquery'));  //adds pop-up ability
     127
     128}
    124129
    125130
    126131function wprssmi_localize_vars() {
    127     return array(
    128         'delcat' => __('Delete this category', 'wp-rss-multi-importer'),
    129         'delfeed' => __('Delete this feed', 'wp-rss-multi-importer'),
    130         'intcheck' => __('This must be an integer', 'wp-rss-multi-importer'),
    131         'urlcheck' => __('Bad URL- feeds start with http', 'wp-rss-multi-importer')
    132     );
    133 }
    134 
    135 
    136 
    137 
     132    return array(
     133        'delcat'   => __( 'Delete this category', 'wp-rss-multi-importer' ),
     134        'delfeed'  => __( 'Delete this feed', 'wp-rss-multi-importer' ),
     135        'intcheck' => __( 'This must be an integer', 'wp-rss-multi-importer' ),
     136        'urlcheck' => __( 'Bad URL- feeds start with http', 'wp-rss-multi-importer' )
     137    );
     138}
    138139
    139140
    140141function wprssmi_ajax_load_scripts() {
    141     wp_enqueue_script( 'ajax-template', plugins_url('scripts/ajax.js',dirname(__FILE__)),array('jquery'));
    142     wp_localize_script( 'ajax-template', 'the_ajax_script', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) ); 
    143 
    144 }
    145 
    146 
    147 
    148 
    149 
    150 
    151  
    152    
    153   add_action( 'wp_enqueue_scripts', 'wprssmi_frontend_scripts' );
    154    
    155    function wprssmi_frontend_scripts() {
    156         wp_enqueue_script( 'jquery' ); 
    157    }
    158 
     142    wp_enqueue_script( 'ajax-template', plugins_url( 'scripts/ajax.js', dirname( __FILE__ ) ), array( 'jquery' ) );
     143    wp_localize_script( 'ajax-template', 'the_ajax_script', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) );
     144
     145}
     146
     147
     148add_action( 'wp_enqueue_scripts', 'wprssmi_frontend_scripts' );
     149
     150function wprssmi_frontend_scripts() {
     151    wp_enqueue_script( 'jquery' );
     152}
    159153
    160154
    161155add_action( 'wp_enqueue_scripts', 'wprssmi_tempate_header' );
    162156
    163 function wprssmi_tempate_header(){
    164 
    165         wp_enqueue_style( 'wprssmi_template_styles', plugins_url( 'templates/templates.css', dirname(__FILE__)) );
    166    
    167 }
    168 
    169 
     157function wprssmi_tempate_header() {
     158
     159    wp_enqueue_style( 'wprssmi_template_styles', plugins_url( 'templates/templates.css', dirname( __FILE__ ) ) );
     160
     161}
    170162
    171163
     
    175167
    176168
    177     function wprssmi_header() {       
    178         wp_enqueue_style( 'wprssmi_styles', plugins_url( 'css/styles.css', dirname(__FILE__)) );
    179 
    180     }
    181 
     169function wprssmi_header() {
     170    wp_enqueue_style( 'wprssmi_styles', plugins_url( 'css/styles.css', dirname( __FILE__ ) ) );
     171
     172}
    182173
    183174
    184175/**
    185     * Include Colorbox-related script and CSS in WordPress in footer
    186     */
    187 
    188 
    189 
    190 function rssmi_footer_scripts(){
    191     wp_enqueue_style( 'frontend', plugins_url( 'css/frontend.css', dirname(__FILE__)) );
    192     wp_enqueue_script( 'showexcerpt', plugins_url('scripts/show-excerpt.js', dirname(__FILE__)) );     
    193 }
    194 
    195 function colorbox_scripts(){
    196     wp_enqueue_style( 'wprssmi_colorbox', plugins_url( 'css/colorbox.css', dirname(__FILE__)) );
    197     wp_enqueue_script( 'jquery.colorbox-min', plugins_url( 'scripts/jquery.colorbox-min.js', dirname(__FILE__)) );
    198  wp_enqueue_script( 'wprssmi_detect_mobile', plugins_url( 'scripts/detect-mobile.js', dirname(__FILE__)) );
     176 * Include Colorbox-related script and CSS in WordPress in footer
     177 */
     178
     179
     180function rssmi_footer_scripts() {
     181    wp_enqueue_style( 'frontend', plugins_url( 'css/frontend.css', dirname( __FILE__ ) ) );
     182    wp_enqueue_script( 'showexcerpt', plugins_url( 'scripts/show-excerpt.js', dirname( __FILE__ ) ) );
     183}
     184
     185function colorbox_scripts() {
     186    wp_enqueue_style( 'wprssmi_colorbox', plugins_url( 'css/colorbox.css', dirname( __FILE__ ) ) );
     187    wp_enqueue_script( 'jquery.colorbox-min', plugins_url( 'scripts/jquery.colorbox-min.js', dirname( __FILE__ ) ) );
     188    wp_enqueue_script( 'wprssmi_detect_mobile', plugins_url( 'scripts/detect-mobile.js', dirname( __FILE__ ) ) );
    199189    //echo "<script type='text/javascript'>jQuery(document).ready(function(){ jQuery('a.colorbox').colorbox({iframe:true, width:'80%', height:'80%'})});</script>";
    200     echo "<script type='text/javascript'>jQuery(document).ready(function(){ jQuery('a.colorbox').colorbox({iframe:true, width:'80%', height:'80%'});jQuery('a.rssmi_youtube').colorbox({iframe:true, innerWidth:425, innerHeight:344})});</script>";   
    201    
    202 }
    203 
    204 
    205 
    206 
    207 
    208 
    209 
    210 
    211 
    212 function widget_footer_scripts(){
    213     wp_enqueue_style( 'newstickercss', plugins_url( 'css/newsticker.css', dirname(__FILE__)) );
    214     wp_enqueue_script( 'newsticker', plugins_url( 'scripts/newsticker.js', dirname(__FILE__)) );   
    215     echo "<script type='text/javascript'>jQuery(document).ready(function () {jQuery('#newsticker').vscroller();});</script>"; 
     190    echo "<script type='text/javascript'>jQuery(document).ready(function(){ jQuery('a.colorbox').colorbox({iframe:true, width:'80%', height:'80%'});jQuery('a.rssmi_youtube').colorbox({iframe:true, innerWidth:425, innerHeight:344})});</script>";
     191
     192}
     193
     194
     195function widget_footer_scripts() {
     196    wp_enqueue_style( 'newstickercss', plugins_url( 'css/newsticker.css', dirname( __FILE__ ) ) );
     197    wp_enqueue_script( 'newsticker', plugins_url( 'scripts/newsticker.js', dirname( __FILE__ ) ) );
     198    echo "<script type='text/javascript'>jQuery(document).ready(function () {jQuery('#newsticker').vscroller();});</script>";
    216199}
    217200
     
    220203
    221204
    222 
    223 function vertical_scroll_footer_scripts(){
    224         wp_enqueue_script( 'vertical_scroll', plugins_url( 'scripts/jquery.vticker.js', dirname(__FILE__)) ); 
    225    
    226 }
    227 
    228 
    229 
    230     function smooth_scroll_scripts(){
    231         wp_enqueue_script( 'jquery_custom_ui', plugins_url( 'scripts/scroll/jquery-ui-1.8.23.custom.js', dirname(__FILE__)) , array('jquery'));     
    232             wp_enqueue_script( 'mousewheel', plugins_url( 'scripts/scroll/jquery.mousewheel.min.js', dirname(__FILE__)) , array('jquery')); 
    233                 wp_enqueue_script( 'kinetic', plugins_url( 'scripts/scroll/jquery.kinetic.js', dirname(__FILE__)) , array('jquery'));   
    234                     wp_enqueue_script( 'smoothscroll', plugins_url( 'scripts/scroll/jquery.smoothdivscroll-1.3-min.js', dirname(__FILE__)) , array('jquery'));
    235 
    236  }
    237 
    238 
    239 
     205function vertical_scroll_footer_scripts() {
     206    wp_enqueue_script( 'vertical_scroll', plugins_url( 'scripts/jquery.vticker.js', dirname( __FILE__ ) ) );
     207
     208}
     209
     210
     211function smooth_scroll_scripts() {
     212    wp_enqueue_script( 'jquery_custom_ui', plugins_url( 'scripts/scroll/jquery-ui-1.8.23.custom.js', dirname( __FILE__ ) ), array( 'jquery' ) );
     213    wp_enqueue_script( 'mousewheel', plugins_url( 'scripts/scroll/jquery.mousewheel.min.js', dirname( __FILE__ ) ), array( 'jquery' ) );
     214    wp_enqueue_script( 'kinetic', plugins_url( 'scripts/scroll/jquery.kinetic.js', dirname( __FILE__ ) ), array( 'jquery' ) );
     215    wp_enqueue_script( 'smoothscroll', plugins_url( 'scripts/scroll/jquery.smoothdivscroll-1.3-min.js', dirname( __FILE__ ) ), array( 'jquery' ) );
     216
     217}
    240218
    241219
  • wp-rss-multi-importer/trunk/inc/upgrade.php

    r976190 r989112  
    11<?php
    22
    3 add_action('admin_init','upgrade_db'); // Used starting in version 2.22...afterwards, version is being stored in db
    4 
    5 function upgrade_db() {  //beginning of upgrade function
    6    
    7     $option_settings = get_option('rss_import_options'); //get shortcode settings (has the plugin version)
    8     $items_options=get_option('rss_import_items'); // get rss feeds
    9     $categoryoptions=get_option('rss_import_categories_images'); //category images
    10     $post_options = get_option('rss_post_options'); //autoPost options
    11     $wprssmi_admin_options = get_option( 'rss_admin_options' );  // admin settings
    12     $catOptions= get_option( 'rss_import_categories' );  //categories
    13    
     3add_action( 'admin_init', 'upgrade_db' ); // Used starting in version 2.22...afterwards, version is being stored in db
     4
     5function upgrade_db() { //beginning of upgrade function
     6
     7    $option_settings       = get_option( 'rss_import_options' ); //get shortcode settings (has the plugin version)
     8    $items_options         = get_option( 'rss_import_items' ); // get rss feeds
     9    $categoryoptions       = get_option( 'rss_import_categories_images' ); //category images
     10    $post_options          = get_option( 'rss_post_options' ); //autoPost options
     11    $wprssmi_admin_options = get_option( 'rss_admin_options' ); // admin settings
     12    $catOptions            = get_option( 'rss_import_categories' ); //categories
     13
    1414//  $wprssmi_admin_options['old_plugin_version'] = $option_settings['plugin_version'];
    15     $old_version=$option_settings['plugin_version'];
    16     $wprssmi_admin_options['plugin_version'] = number_format(WP_RSS_MULTI_VERSION, 2);
     15    $old_version = '';
     16    if ( isset( $option_settings['plugin_version'] ) ) {
     17        $old_version = $option_settings['plugin_version'];
     18    }
     19    $wprssmi_admin_options['plugin_version'] = number_format( WP_RSS_MULTI_VERSION, 2 );
    1720
    1821    update_option( 'rss_admin_options', $wprssmi_admin_options ); //put the current version in the database
    19    
    20    
     22
    2123
    2224    //indicate that new installs and beta testers are already activated
    2325
    24     if (empty($items_options)  || (isset($wprssmi_admin_options['activate']) && $wprssmi_admin_options['activate']==1))  {
    25         $wprssmi_admin_options['activate']=1; 
    26     }else{
    27         $wprssmi_admin_options['activate']=0;
    28     }
    29         update_option( 'rss_admin_options', $wprssmi_admin_options );  //update the database
    30        
    31        
     26    if ( empty( $items_options ) || ( isset( $wprssmi_admin_options['activate'] ) && $wprssmi_admin_options['activate'] == 1 ) ) {
     27        $wprssmi_admin_options['activate'] = 1;
     28    }
     29    else {
     30        $wprssmi_admin_options['activate'] = 0;
     31    }
     32    update_option( 'rss_admin_options', $wprssmi_admin_options ); //update the database
     33
     34
    3235    //  ADD THIS BEFORE LAUNCH AND MAKE VERSION 3.00
    33             if(floatval($old_version)==2.68){
    34                     rssmi_activate_now();
    35             }
    36 
    37 
    38    
    39     if ( !empty($items_options) && empty($option_settings)) {  // this transfers data to new table if upgrading
    40             add_option( 'rss_import_options', $items_options, '', '');
    41     }
    42    
    43         if(!empty($option_settings)){  //only if not a new install
    44     if (!isset($option_settings['template'])|| $option_settings['template']==='') {
    45        
    46         foreach ( $option_settings as $key => $value) {
    47             $template_settings[ $key ] = $value;
    48         }
    49         $template_settings['template'] = 'default.php';
     36    if ( floatval( $old_version ) == 2.68 ) {
     37        rssmi_activate_now();
     38    }
     39
     40
     41    if ( ! empty( $items_options ) && empty( $option_settings ) ) { // this transfers data to new table if upgrading
     42        add_option( 'rss_import_options', $items_options, '', '' );
     43    }
     44
     45    if ( ! empty( $option_settings ) ) { //only if not a new install
     46        if ( ! isset( $option_settings['template'] ) || $option_settings['template'] === '' ) {
     47
     48            foreach ( $option_settings as $key => $value ) {
     49                $template_settings[$key] = $value;
     50            }
     51            $template_settings['template'] = 'default.php';
    5052            update_option( 'rss_import_options', $template_settings );
    51     }
    52 
    53     }
    54    
    55    
    56    
    57     if (empty($post_options)){
    58    
    59     $post_settings = array(
    60         'active'=> 0,
    61         'post_status' => 'publish',
    62         'maxperfetch' => 5,
    63         'maxfeed' => 5,
    64         'maximgwidth' =>150,
    65         'category' => 0         
     53        }
     54
     55    }
     56
     57
     58    if ( empty( $post_options ) ) {
     59
     60        $post_settings = array(
     61            'active'      => 0,
     62            'post_status' => 'publish',
     63            'maxperfetch' => 5,
     64            'maxfeed'     => 5,
     65            'maximgwidth' => 150,
     66            'category'    => 0
     67        );
     68
     69        update_option( 'rss_post_options', $post_settings );
     70    }
     71
     72    //this is for adding multiple categories to the feed to post feature (version 2.47)
     73
     74
     75    if ( ! empty( $post_options ) ) {
     76
     77        if ( ! isset( $post_options['categoryid']['plugcatid'] ) || $post_options['categoryid']['plugcatid'] === '' ) {
     78
     79
     80            foreach ( $post_options as $key => $value ) {
     81                $post_settings[$key] = $value;
     82            }
     83
     84            $post_settings['categoryid']['plugcatid'][1] = '';
     85            if ( isset( $post_options['category'] ) ) {
     86                $post_settings['categoryid']['plugcatid'][1] = $post_options['category'];
     87            }
     88
     89            $post_settings['categoryid']['wpcatid'][1]  = '';
     90            if ( isset( $post_options['wpcategory'] ) ) {
     91                $post_settings['categoryid']['wpcatid'][1]   = $post_options['wpcategory'];
     92            }
     93            update_option( 'rss_post_options', $post_settings );
     94        }
     95    }
     96
     97
     98    if (
     99        ! empty( $post_options ) &&
     100        isset( $post_options['categoryid'] ) &&
     101        ! is_array( $post_options['categoryid']['wpcatid'][1] )
     102    ) {
     103
     104        foreach ( $post_options as $key => $value ) {
     105            if ( $key != 'categoryid' ) {
     106                $post_settings[$key] = $value;
     107            }
     108        }
     109
     110        $catsize        = count( $catOptions );
     111        $postoptionsize = $catsize / 2;
     112
     113        for ( $q = 1; $q <= $postoptionsize; $q ++ ) {
     114            $post_settings['categoryid']['plugcatid'][$q]  = $post_options['categoryid']['plugcatid'][$q];
     115            $post_settings['categoryid']['wpcatid'][$q][1] = $post_options['categoryid']['wpcatid'][$q];
     116        }
     117
     118        update_option( 'rss_post_options', $post_settings );
     119    }
     120
     121
     122    if ( ! empty( $categoryoptions ) && ! is_array( $categoryoptions[1] ) ) {
     123
     124        foreach ( $categoryoptions as $key => $value ) {
     125            $cat_settings[$key]['imageURL'] = $value;
     126            $cat_settings[$key]['tags']     = '';
     127        }
     128        update_option( 'rss_import_categories_images', $cat_settings );
     129
     130
     131    }
     132
     133    //for resetting the admin message
     134    if ( isset( $plugin_version ) && $plugin_version < 2.40 ) {
     135        $wprssmi_admin_options['dismiss_slug'] = 'false';
     136        //update_option( 'wprssmi_admin_options', $post_settings );
     137    }
     138
     139
     140    if ( empty( $option_settings ) ) {
     141
     142        $option_default_settings = array(
     143            'sortbydate'      => 0,
     144            'pag'             => 0,
     145            'targetWindow'    => 0,
     146            'maxfeed'         => 4,
     147            'sourcename'      => 'Source',
     148            'showcategory'    => 0,
     149            'noFollow'        => 0,
     150            'showdesc'        => 1,
     151            'descnum'         => 50,
     152            'floatType'       => 1,
     153            'adjustImageSize' => 1,
     154            'showsocial'      => 0
     155        );
     156        update_option( 'rss_import_options', $option_default_settings );
     157
     158    }
     159
     160
     161} //  end of upgrade function
     162
     163
     164function rssmi_get_wp_categories( $catid ) {
     165    $option_post_items = get_option( 'rss_post_options' );
     166    if ( ! empty( $option_post_items['categoryid'] ) ) {
     167        $catkey  = array_search( $catid, $option_post_items['categoryid']['plugcatid'] );
     168        $wpcatid = $option_post_items['categoryid']['wpcatid'][$catkey];
     169    }
     170    else {
     171        $wpcatid = 0;
     172    }
     173    return $wpcatid;
     174}
     175
     176
     177// insert date format 3.00
     178$rssmi_global_options = get_option( 'rssmi_global_options' );
     179if ( empty( $rssmi_global_options ) ) {
     180    $date_default_settings = array(
     181        'date_format'     => 'D, M d, Y',
     182        'fetch_schedule'  => 5,
     183        'expiration'      => 7,
     184        'single_feed_max' => 20
    66185    );
    67    
    68         update_option( 'rss_post_options', $post_settings );
    69     }
    70    
    71     //this is for adding multiple categories to the feed to post feature (version 2.47)
    72    
    73 
    74     if (!empty($post_options)){
    75        
    76         if (!isset($post_options['categoryid']['plugcatid'])|| $post_options['categoryid']['plugcatid']==='') {
    77    
    78        
    79         foreach ( $post_options as $key => $value) {
    80             $post_settings[ $key ] = $value;
    81             }
    82    
    83             $post_settings['categoryid']['plugcatid'][1]=$post_options['category'];
    84             $post_settings['categoryid']['wpcatid'][1]=$post_options['wpcategory'];
    85             update_option( 'rss_post_options', $post_settings );
    86         }
    87     }
    88 
    89 
    90 
    91     if (!empty($post_options) && !is_array($post_options['categoryid']['wpcatid'][1])) {
    92 
    93 
    94         foreach ( $post_options as $key => $value) {
    95             if ($key!='categoryid'){
    96             $post_settings[ $key ] = $value;
    97             }
    98         }
    99        
    100         $catsize = count($catOptions);
    101         $postoptionsize= $catsize/2;
    102 
    103         for ( $q=1; $q<=$postoptionsize; $q++ ){
    104             $post_settings['categoryid']['plugcatid'][$q]=$post_options['categoryid']['plugcatid'][$q];
    105             $post_settings['categoryid']['wpcatid'][$q][1]=$post_options['categoryid']['wpcatid'][$q];
    106         }
    107 
    108             update_option( 'rss_post_options', $post_settings );
    109     }
    110 
    111    
    112    
    113     if (!empty($categoryoptions) && !is_array($categoryoptions[1]) ){
    114    
    115         foreach ( $categoryoptions as $key => $value) {
    116             $cat_settings[$key]['imageURL']=$value;
    117             $cat_settings[$key]['tags']='';
    118         }
    119     update_option( 'rss_import_categories_images', $cat_settings );
    120 
    121    
    122 }
    123    
    124     //for resetting the admin message
    125     if (isset($plugin_version) && $plugin_version<2.40){
    126     $wprssmi_admin_options['dismiss_slug'] ='false';
    127     //update_option( 'wprssmi_admin_options', $post_settings );
    128     }
    129    
    130 
    131    
    132     if (empty($option_settings)){
    133 
    134         $option_default_settings = array(
    135         'sortbydate' => 0,
    136         'pag' => 0,
    137         'targetWindow' => 0,
    138         'maxfeed'=> 4,
    139         'sourcename' => 'Source',
    140         'showcategory' => 0,
    141         'noFollow' => 0,
    142         'showdesc' => 1,
    143         'descnum' => 50,
    144         'floatType' => 1,
    145         'adjustImageSize' => 1,
    146         'showsocial' => 0
    147         );
    148     update_option( 'rss_import_options', $option_default_settings );
    149 
    150     }
    151    
    152 
    153 }   //  end of upgrade function
    154 
    155 
    156 
    157 function rssmi_get_wp_categories($catid){
    158     $option_post_items = get_option( 'rss_post_options' );
    159     if (!empty($option_post_items['categoryid'])){
    160         $catkey=array_search($catid, $option_post_items['categoryid']['plugcatid']);
    161         $wpcatid=$option_post_items['categoryid']['wpcatid'][$catkey];
    162     }else{
    163         $wpcatid=0;
    164     }
    165     return $wpcatid;
    166 }
    167 
    168 
    169 
    170 // insert date format 3.00
    171 $rssmi_global_options = get_option( 'rssmi_global_options' );
    172 if (empty($rssmi_global_options)){
    173     $date_default_settings = array(
    174     'date_format' => 'D, M d, Y',
    175     'fetch_schedule'=> 5,
    176     'expiration'=> 7,
    177     'single_feed_max'=> 20
    178     );
    179 
    180 update_option( 'rssmi_global_options', $date_default_settings );
    181 
    182 }
    183 
    184 
    185 function rssmi_activate_upgrade(){
     186
     187    update_option( 'rssmi_global_options', $date_default_settings );
     188
     189}
     190
     191
     192function rssmi_activate_upgrade() {
    186193//this upgrades for 2.70 - only if upgrading
    187194//2.68 is beta version, so don't upgrade database for beta users
    188195
    189 $option_items = get_option( 'rss_import_items' );
    190 $wprssmi_admin_options = get_option( 'rss_admin_options' );
     196    $option_items          = get_option( 'rss_import_items' );
     197    $wprssmi_admin_options = get_option( 'rss_admin_options' );
    191198
    192199//if (!empty($option_items) && floatval($old_version)<WP_RSS_MULTI_VERSION and floatval($old_version)<2.68){
    193    
    194 if (!isset($wprssmi_admin_options['activate']) || $wprssmi_admin_options['activate']==0)    {
    195 
    196    
    197     $post_options = get_option('rss_post_options');
    198     $bloguserid=$post_options['bloguserid'];
    199     if(is_null($bloguserid)){$bloguserid=1;}
    200 $option_values = array_values($option_items);
    201 remove_action('save_post', 'rssmi_save_custom_fields');
    202 remove_action('wp_insert_post', 'rssmi_fetch_feed_items');
    203 for ($i = 0; $i <= count($option_items) - 1; $i++) {
    204     $feed_item = array(
    205         'post_title' => $option_values[$i],
    206         'post_content' => '',
    207         'post_status' => 'publish',
    208         'post_type' => 'rssmi_feed'
    209     );
    210     $inserted_ID = wp_insert_post( $feed_item );
    211     $i=$i+1;
    212     update_post_meta($inserted_ID,"rssmi_url", $option_values[$i]);
    213     $i=$i+1;
    214     update_post_meta($inserted_ID,"rssmi_cat", $option_values[$i]);
    215     update_post_meta($inserted_ID,"rssmi_user", $bloguserid);
    216     rssmi_fetch_feed_items($inserted_ID);
    217     unset($feed_item);
    218    
    219 }
    220     add_action( 'save_post', 'rssmi_save_custom_fields' );
    221     add_action('wp_insert_post', 'rssmi_fetch_feed_items');
     200
     201    if ( ! isset( $wprssmi_admin_options['activate'] ) || $wprssmi_admin_options['activate'] == 0 ) {
     202
     203
     204        $post_options = get_option( 'rss_post_options' );
     205        $bloguserid   = $post_options['bloguserid'];
     206        if ( is_null( $bloguserid ) ) {
     207            $bloguserid = 1;
     208        }
     209        $option_values = array_values( $option_items );
     210        remove_action( 'save_post', 'rssmi_save_custom_fields' );
     211        remove_action( 'wp_insert_post', 'rssmi_fetch_feed_items' );
     212        for ( $i = 0; $i <= count( $option_items ) - 1; $i ++ ) {
     213            $feed_item   = array(
     214                'post_title'   => $option_values[$i],
     215                'post_content' => '',
     216                'post_status'  => 'publish',
     217                'post_type'    => 'rssmi_feed'
     218            );
     219            $inserted_ID = wp_insert_post( $feed_item );
     220            $i           = $i + 1;
     221            update_post_meta( $inserted_ID, "rssmi_url", $option_values[$i] );
     222            $i = $i + 1;
     223            update_post_meta( $inserted_ID, "rssmi_cat", $option_values[$i] );
     224            update_post_meta( $inserted_ID, "rssmi_user", $bloguserid );
     225            rssmi_fetch_feed_items( $inserted_ID );
     226            unset( $feed_item );
     227
     228        }
     229        add_action( 'save_post', 'rssmi_save_custom_fields' );
     230        add_action( 'wp_insert_post', 'rssmi_fetch_feed_items' );
    222231//  delete_option('rss_import_items');
    223     //  set activate to 1
    224         $wprssmi_admin_options['activate']=1; 
     232        //  set activate to 1
     233        $wprssmi_admin_options['activate'] = 1;
    225234        update_option( 'rss_admin_options', $wprssmi_admin_options );
    226 }
    227 }
    228 
    229 
    230 function rssmi_check_didUpgrade(){
    231     $option_items = get_option( 'rss_import_items' );
     235    }
     236}
     237
     238
     239function rssmi_check_didUpgrade() {
     240    $option_items          = get_option( 'rss_import_items' );
    232241    $wprssmi_admin_options = get_option( 'rss_admin_options' );
    233242
    234    
    235     if ((isset($wprssmi_admin_options['activate']) && $wprssmi_admin_options['activate']==1) || empty($option_items)){
    236         $isActivated=1;
    237     }else{
    238         $isActivated=0;
    239     }
    240     return  $isActivated;
    241    
    242 }
    243 
    244 function rssmi_activate_now(){
    245 $wprssmi_admin_options = get_option( 'rss_admin_options' );
    246 $wprssmi_admin_options['activate']=1; 
    247 update_option( 'rss_admin_options', $wprssmi_admin_options );
    248    
     243
     244    if ( ( isset( $wprssmi_admin_options['activate'] ) && $wprssmi_admin_options['activate'] == 1 ) || empty( $option_items ) ) {
     245        $isActivated = 1;
     246    }
     247    else {
     248        $isActivated = 0;
     249    }
     250    return $isActivated;
     251
     252}
     253
     254function rssmi_activate_now() {
     255    $wprssmi_admin_options             = get_option( 'rss_admin_options' );
     256    $wprssmi_admin_options['activate'] = 1;
     257    update_option( 'rss_admin_options', $wprssmi_admin_options );
     258
    249259}
    250260
    251261//UPGRADE NOTICES
    252262function rssmi_admin_warnings() {
    253    
    254     if( current_user_can('activate_plugins') ){
    255 
    256 
    257             if(rssmi_check_didUpgrade()==0){ //restrict this to the plugin pages!!!
    258                
    259                
     263
     264    if ( current_user_can( 'activate_plugins' ) ) {
     265
     266
     267        if ( rssmi_check_didUpgrade() == 0 ) { //restrict this to the plugin pages!!!
     268
     269
    260270            //  if ((isset( $_GET['post_type'] )) && (strpos("rssmi_feed",$_GET['post_type'] ,0)!==false) || ( isset( $_GET['page'] )) && ((strpos("wprssmi",$_GET['page'] ,0)!==false) || (strpos('wprssmi',$_GET['page'] )!==false ) || (strpos('wprssmi_options',$_GET['page'] )!==false ) || (strpos('wprssmi_options2',$_GET['page'] )!==false ) || (strpos('wprssmi_options3',$_GET['page'] )!==false ) || (strpos('wprssmi_options4',$_GET['page'] )!==false ) || (strpos('wprssmi_options9',$_GET['page'] )!==false )  || (strpos('wprssmi_options5',$_GET['page'] )!==false ) || (strpos('wprssmi_options8',$_GET['page'] )!==false )|| (strpos('wprssmi_options7',$_GET['page'] )!==false ))) {
    261                 if (rssmi_is_plugin_page()==1){
    262                
    263                
    264                
     271            if ( rssmi_is_plugin_page() == 1 ) {
     272
     273
    265274                ?>
    266275                <div id="upgrade_message" class="error">
    267                     <p><?php echo sprintf ( __( 'Thank you for upgrading to the new version of Multi-Importer.  <br>To activate the new features you need to upgrade the database for the plugin.  <br>No problem.  Just go to the <a href="%s">Start Here page</a> and follow the simple directions. Sorry for the extra step! '), 'admin.php?page=wprssmi' ); ?></p>
     276                    <p><?php echo sprintf( __( 'Thank you for upgrading to the new version of Multi-Importer.  <br>To activate the new features you need to upgrade the database for the plugin.  <br>No problem.  Just go to the <a href="%s">Start Here page</a> and follow the simple directions. Sorry for the extra step! ' ), 'admin.php?page=wprssmi' ); ?></p>
    268277                </div>
    269                 <?php       
    270             }
    271         }
    272     }   
    273        
    274        
    275 }
    276 add_action ( 'admin_notices', 'rssmi_admin_warnings', 100 );
     278            <?php
     279            }
     280        }
     281    }
     282
     283
     284}
     285
     286add_action( 'admin_notices', 'rssmi_admin_warnings', 100 );
    277287
    278288
  • wp-rss-multi-importer/trunk/readme.txt

    r976544 r989112  
    11=== WP RSS Multi Importer ===
    2 Contributors: amweiss98
     2Contributors: amweiss98, properwp
    33Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=M6GC7V8BARAJL
    44Tags: rss, atom, feeds, aggregation, aggregator, import, syndication, autoblog, widget
    55Requires at least: 3.3
    6 Tested up to: 3.9.2
    7 Stable tag: 3.11
     6Tested up to: 4.0
     7Stable tag: 3.12
    88Aggregate RSS feeds. AutoPost or use shortcode, excerpts w/ images, 13 templates, categorize and more.
    99
    1010== Description ==
    1111
    12 All-In-One totally free solution for importing, merging and displaying RSS and Atom feeds on your Wordpress site. Highly rated (in Top 25 of Wordpress plugins). Using this plugin you can do 4 things (separately or at the same time):
     12All-In-One totally free solution for importing, merging and displaying RSS and Atom feeds on your Wordpress site. Using this plugin you can do 4 things (separately or at the same time):
    1313
    1414* Display the aggregated feed items on a page in one of __13 different templates that you can customize__
     
    115115
    116116== Changelog ==
     117
     118= Version 3.12 (2014-9-13) =
     119* Fixed: Various issues reported during the last few weeks.
     120* Enhanced: Manually deleting posts caused by the plugin will now also delete its associated featured image.
     121* Enhanced: Share on LinkedIn now added to social sharing option for AutoPost and default shortcode template.
     122* NEW: Only bring in items newer than n number of days old.
    117123
    118124= Version 3.11 (2014-9-1) =
  • wp-rss-multi-importer/trunk/templates/default.php

    r964637 r989112  
    126126   
    127127    if ($showsocial==1){
    128      $readable .=  '  <span class="socialicons"><a href="http://www.facebook.com/sharer/sharer.php?u='.$items["mylink"].'"><img src="'.WP_RSS_MULTI_IMAGES.'facebook.png"/></a>&nbsp;&nbsp;<a href="http://twitter.com/intent/tweet?text='.rawurlencode($items["mytitle"]).'%20'.$items["mylink"].'"><img src="'.WP_RSS_MULTI_IMAGES.'twitter.png"/></a>&nbsp;&nbsp;<a href="http://plus.google.com/share?url='.rawurlencode($items["mylink"]).'"><img src="'.WP_RSS_MULTI_IMAGES.'gplus.png"/></a></span>';
     128     $readable .=  '  <span class="socialicons"><a href="http://www.facebook.com/sharer/sharer.php?u='.$items["mylink"].'"><img src="'.WP_RSS_MULTI_IMAGES.'facebook.png"/></a>&nbsp;&nbsp;<a href="http://twitter.com/intent/tweet?text='.rawurlencode($items["mytitle"]).'%20'.$items["mylink"].'"><img src="'.WP_RSS_MULTI_IMAGES.'twitter.png"/></a>&nbsp;&nbsp;<a href="http://plus.google.com/share?url='.rawurlencode($items["mylink"]).'"><img src="'.WP_RSS_MULTI_IMAGES.'gplus.png"/></a>&nbsp;&nbsp;<a href="http://www.linkedin.com/shareArticle?mini=true&url='.rawurlencode($items["mylink"]).'"><img src="'.WP_RSS_MULTI_IMAGES.'linkedin.png"/></a></span>';
    129129    }
    130130   
  • wp-rss-multi-importer/trunk/wp-rss-multi-importer.php

    r976544 r989112  
    33  Plugin URI: http://www.wprssimporter.com/
    44  Description: All-in-one solution for importing & merging multiple feeds. Make blog posts or display on a page, excerpts w/ images, 13 templates, categorize and more.
    5   Version: 3.11
     5  Version: 3.12
    66  Author: Allen Weiss
    77  Author URI: http://www.wprssimporter.com/
     
    1010
    1111
    12 
    13 
    1412/* Set the version number of the plugin. */
    15 define( 'WP_RSS_MULTI_VERSION', 3.11 );
    16 
    17  /* Set constant path to the plugin directory. */
    18 define( 'WP_RSS_MULTI_PATH', plugin_dir_path( __FILE__ ) ); 
    19 
    20  /* Set constant url to the plugin directory. */
     13define( 'WP_RSS_MULTI_VERSION', 3.12 );
     14
     15/* Set constant path to the plugin directory. */
     16define( 'WP_RSS_MULTI_PATH', plugin_dir_path( __FILE__ ) );
     17
     18/* Set constant url to the plugin directory. */
    2119define( 'WP_RSS_MULTI_URL', plugin_dir_url( __FILE__ ) );
    2220
     
    4038
    4139/* Load the template functions file. */
    42 require_once ( WP_RSS_MULTI_INC . 'template_functions.php' );
     40require_once( WP_RSS_MULTI_INC . 'template_functions.php' );
    4341
    4442/* Load the messages file. */
    45 require_once ( WP_RSS_MULTI_INC . 'panel_messages.php' );
     43require_once( WP_RSS_MULTI_INC . 'panel_messages.php' );
    4644
    4745/* Load the database functions file. */
    48 require_once ( WP_RSS_MULTI_INC . 'db_functions.php' );
     46require_once( WP_RSS_MULTI_INC . 'db_functions.php' );
    4947
    5048/* Load the excerpt functions file. */
    51 require_once ( WP_RSS_MULTI_INC . 'excerpt_functions.php' );
     49require_once( WP_RSS_MULTI_INC . 'excerpt_functions.php' );
    5250
    5351/* Load the cron file. */
    54 require_once ( WP_RSS_MULTI_INC . 'cron.php' );
     52require_once( WP_RSS_MULTI_INC . 'cron.php' );
    5553
    5654/* Load the options file. */
    57 require_once ( WP_RSS_MULTI_INC . 'options.php' );
     55require_once( WP_RSS_MULTI_INC . 'options.php' );
    5856
    5957/* Load the widget functions file. */
    60 require_once ( WP_RSS_MULTI_INC . 'rss_multi_importer_widget.php' );
     58require_once( WP_RSS_MULTI_INC . 'rss_multi_importer_widget.php' );
    6159
    6260/* Load the upgrade file. */
    63 require_once ( WP_RSS_MULTI_INC . 'upgrade.php' );
     61require_once( WP_RSS_MULTI_INC . 'upgrade.php' );
    6462
    6563/* Load the admin functions file. */
    66 require_once ( WP_RSS_MULTI_INC . 'admin_functions.php' );
    67 
    68 require_once ( WP_RSS_MULTI_INC . 'import_feeds.php' );
     64require_once( WP_RSS_MULTI_INC . 'admin_functions.php' );
     65
     66require_once( WP_RSS_MULTI_INC . 'import_feeds.php' );
    6967
    7068/* Load the scripts files. */
    71 require_once ( WP_RSS_MULTI_INC . 'scripts.php' );
     69require_once( WP_RSS_MULTI_INC . 'scripts.php' );
    7270
    7371/* Load the feed files. */
    74 require_once ( WP_RSS_MULTI_INC . 'rss_feed.php' );
     72require_once( WP_RSS_MULTI_INC . 'rss_feed.php' );
    7573
    7674/* Load the import posts files. */
    77 require_once(  WP_RSS_MULTI_INC . 'import_posts.php');
    78 
    79 /* Load the custom posts files. */ 
    80 require_once(  WP_RSS_MULTI_INC . 'custom_posts.php'); 
     75require_once( WP_RSS_MULTI_INC . 'import_posts.php' );
     76
     77/* Load the custom posts files. */
     78require_once( WP_RSS_MULTI_INC . 'custom_posts.php' );
    8179
    8280/* Load the feed to post list files. */
    83 require_once(  WP_RSS_MULTI_INC . 'ftp_list_table.php'); 
     81require_once( WP_RSS_MULTI_INC . 'ftp_list_table.php' );
    8482
    8583/* Load the admin_init files. */
    86 require_once ( WP_RSS_MULTI_INC . 'admin_init.php' );
     84require_once( WP_RSS_MULTI_INC . 'admin_init.php' );
    8785
    8886/* Load the upload feed files. */
    89 require_once ( WP_RSS_MULTI_INC . 'textbox-to-db.php' );
     87require_once( WP_RSS_MULTI_INC . 'textbox-to-db.php' );
    9088
    9189/* Load the diagnostics  files. */
    92 require_once ( WP_RSS_MULTI_INC . 'diagnostics.php' );
     90require_once( WP_RSS_MULTI_INC . 'diagnostics.php' );
    9391
    9492/* Load the export  files. */
    95 require_once ( WP_RSS_MULTI_INC . 'export.php' );
     93require_once( WP_RSS_MULTI_INC . 'export.php' );
    9694
    9795/* Load the global settings files. */
    98 require_once ( WP_RSS_MULTI_INC . 'global_settings.php' );
     96require_once( WP_RSS_MULTI_INC . 'global_settings.php' );
    9997
    10098
    10199register_activation_hook( __FILE__, 'wp_rss_multi_importer_activate' );
    102100
     101register_deactivation_hook(__FILE__, 'wp_rss_multi_deactivation_event');
     102
     103function wp_rss_multi_deactivation_event(){
     104    wp_clear_scheduled_hook('wp_rss_multi_event_importfeeds');
     105    wp_clear_scheduled_hook('wp_rss_multi_event_feedtopost');
     106    wp_clear_scheduled_hook('wp_rss_multi_event_delete_custom_posts');
     107    wp_clear_scheduled_hook('wp_rss_multi_event');
     108}
    103109
    104110
    105111function rssmi_plugin_update_info() {
    106     if (rssmi_remoteFileExists("http://www.wprssimporter.com/a/plugin-updates.txt")===True) {
    107     $info = wp_remote_fopen("http://www.wprssimporter.com/a/plugin-updates.txt");
    108     echo '<br />' . strip_tags( $info, "<br><a><b><i><span>" );
    109         }
     112    if ( rssmi_remoteFileExists( "http://www.wprssimporter.com/a/plugin-updates.txt" ) === True ) {
     113        $info = wp_remote_fopen( "http://www.wprssimporter.com/a/plugin-updates.txt" );
     114        echo '<br />' . strip_tags( $info, "<br><a><b><i><span>" );
     115    }
    110116}
    111 add_action('in_plugin_update_message-'.plugin_basename(__FILE__), 'rssmi_plugin_update_info');
    112 
    113 
    114    
    115    /**
    116    *  Shortcode setup and call (shortcode is [wp_rss_multi_importer]) with options
    117    */
    118    
    119    add_shortcode('wp_rss_multi_importer','wp_rss_multi_importer_shortcode');
    120  
     117
     118add_action( 'in_plugin_update_message-' . plugin_basename( __FILE__ ), 'rssmi_plugin_update_info' );
     119
     120
     121/**
     122 *  Shortcode setup and call (shortcode is [wp_rss_multi_importer]) with options
     123 */
     124
     125add_shortcode( 'wp_rss_multi_importer', 'wp_rss_multi_importer_shortcode' );
     126
    121127
    122128function wp_rss_mi_lang_init() {
    123   load_plugin_textdomain( 'wp-rss-multi-importer', false, dirname( plugin_basename( __FILE__ ) ). '/lang/' );  // load the language files
     129    load_plugin_textdomain( 'wp-rss-multi-importer', false, dirname( plugin_basename( __FILE__ ) ) . '/lang/' ); // load the language files
    124130}
    125 add_action('plugins_loaded', 'wp_rss_mi_lang_init');
    126 
    127 
    128 
    129 
    130 function wp_rss_fetchFeed($url, $timeout = 10, $forceFeed=false,$showVideo=0)
    131   {
     131
     132add_action( 'plugins_loaded', 'wp_rss_mi_lang_init' );
     133
     134
     135function wp_rss_fetchFeed( $url, $timeout = 10, $forceFeed = false, $showVideo = 0 ) {
    132136
    133137    $feed = new SimplePie_RSSMI();
    134     $feed->set_feed_url($url);
    135     $feed->force_feed($forceFeed);
     138    $feed->set_feed_url( $url );
     139    $feed->force_feed( $forceFeed );
    136140    $feed->set_autodiscovery_level( SIMPLEPIE_LOCATOR_ALL );
    137     if ($showVideo==1){
     141    if ( $showVideo == 1 ) {
    138142        $strip_htmltags = $feed->strip_htmltags;
    139         array_splice($strip_htmltags, array_search('iframe', $strip_htmltags), 1);
    140         $feed->strip_htmltags($strip_htmltags);
     143        array_splice( $strip_htmltags, array_search( 'iframe', $strip_htmltags ), 1 );
     144        $feed->strip_htmltags( $strip_htmltags );
    141145    }
    142     $feed->enable_cache(false);
    143     $feed->set_timeout($timeout);
     146    $feed->enable_cache( false );
     147    $feed->set_timeout( $timeout );
    144148    $feed->init();
    145149    $feed->handle_content_type();
    146150
    147     return $feed;
    148   }
    149 
    150 
    151 
     151    return $feed;
     152}
    152153
    153154
     
    155156
    156157
    157    
    158    function wp_rss_multi_importer_shortcode($atts=array()){
    159    
    160 
    161 
    162 
    163 
    164    
    165 add_action('wp_footer','rssmi_footer_scripts');
    166 
    167 if(!function_exists("wprssmi_hourly_feed")) {
    168 function wprssmi_hourly_feed() { return 0; }
     158function wp_rss_multi_importer_shortcode( $atts = array() ) {
     159
     160
     161    add_action( 'wp_footer', 'rssmi_footer_scripts' );
     162
     163    if ( ! function_exists( "wprssmi_hourly_feed" ) ) {
     164        function wprssmi_hourly_feed() {
     165            return 0;
     166        }
     167    }
     168    add_filter( 'wp_feed_cache_transient_lifetime', 'wprssmi_hourly_feed' );
     169
     170
     171    $siteurl         = get_site_url();
     172    $cat_options_url = $siteurl . '/wp-admin/options-general.php?page=wp_rss_multi_importer_admin&tab=category_options/';
     173    $images_url      = $siteurl . '/wp-content/plugins/' . basename( dirname( __FILE__ ) ) . '/images';
     174
     175    global $fopenIsSet;
     176    $fopenIsSet = ini_get( 'allow_url_fopen' );
     177
     178    $parms = shortcode_atts( array( //Get shortcode parameters
     179        'category'      => 0,
     180        'hdsize'        => '16px',
     181        'hdweight'      => 400,
     182        'anchorcolor'   => '',
     183        'testyle'       => 'color: #000000; font-weight: bold;margin: 0 0 0.8125em;',
     184        'maximgwidth'   => 150,
     185        'datestyle'     => 'font-style:italic;',
     186        'floattype'     => '',
     187        'showdate'      => 1,
     188        'showgroup'     => 1,
     189        'thisfeed'      => '',
     190        'timer'         => 0,
     191        'dumpthis'      => 0,
     192        'cachetime'     => NULL,
     193        'pinterest'     => 0,
     194        'maxperpage'    => 0,
     195        'excerptlength' => NULL,
     196        'noimage'       => 0,
     197        'sortorder'     => NULL,
     198        'defaultimage'  => NULL,
     199        'nofollow'      => NULL,
     200        'showdesc'      => NULL,
     201        'mytemplate'    => '',
     202        'showmore'      => NULL,
     203        'sourcename'    => '',
     204        'authorprep'    => 'by',
     205        'windowstyle'   => NULL,
     206        'morestyle'     => '[...]'
     207    ), $atts );
     208
     209    $showThisDesc = $parms['showdesc'];
     210    $defaultImage = $parms['defaultimage'];
     211    $sortOrder    = $parms['sortorder'];
     212    $authorPrep   = $parms['authorprep'];
     213    $anchorcolor  = $parms['anchorcolor'];
     214    $datestyle    = $parms['datestyle'];
     215    $hdsize       = $parms['hdsize'];
     216    $thisCat      = $parms['category'];
     217    $parmfloat    = $parms['floattype'];
     218    $catArray     = explode( ",", $thisCat );
     219    $showdate     = $parms['showdate'];
     220    $showgroup    = $parms['showgroup'];
     221    $pshowmore    = $parms['showmore'];
     222    $hdweight     = $parms['hdweight'];
     223    $testyle      = $parms['testyle'];
     224    global $morestyle;
     225    $morestyle = $parms['morestyle'];
     226    global $maximgwidth;
     227    $maximgwidth            = $parms['maximgwidth'];
     228    $thisfeed               = $parms['thisfeed']; // max posts per feed
     229    $timerstop              = $parms['timer'];
     230    $dumpthis               = $parms['dumpthis']; //diagnostic parameter
     231    $cachename              = 'wprssmi_' . $thisCat;
     232    $cachetime              = $parms['cachetime'];
     233    $pnofollow              = $parms['nofollow'];
     234    $pinterest              = $parms['pinterest'];
     235    $parmmaxperpage         = $parms['maxperpage'];
     236    $noimage                = $parms['noimage'];
     237    $mytemplate             = $parms['mytemplate'];
     238    $windowstyle            = $parms['windowstyle'];
     239    $excerptlength          = $parms['excerptlength'];
     240    $parsourcename          = $parms['sourcename'];
     241    $readable               = '';
     242    $options                = get_option( 'rss_import_options', 'option not found' );
     243    $option_items           = get_option( 'rss_import_items', 'option not found' );
     244    $option_category_images = get_option( 'rss_import_categories_images', 'option not found' );
     245    $rssmi_global_options   = get_option( 'rssmi_global_options' );
     246    $suppress_warnings      = ( isset( $rssmi_global_options['suppress_warnings'] ) ? $rssmi_global_options['suppress_warnings'] : 0 );
     247
     248    if ( $option_items == false ) return _e( "You need to set up the WP RSS Multi Importer Plugin before any results will show here.  Just go into the <a href='/wp-admin/options-general.php?page=wp_rss_multi_importer_admin'>settings panel</a> and put in some RSS feeds", 'wp-rss-multi-importer' );
     249
     250
     251    if ( ! empty( $option_items ) ) {
     252
     253//GET PARAMETERS 
     254        global $RSSdefaultImage;
     255        $RSSdefaultImage = $options['RSSdefaultImage']; // 0- process normally, 1=use default for category, 2=replace when no image available
     256        $size            = count( $option_items );
     257        $sortDir         = $options['sortbydate']; // 1 is ascending
     258        $stripAll        = ( isset( $options['stripAll'] ) ? $options['stripAll'] : null );
     259        $stripSome       = ( isset( $options['stripSome'] ) ? $options['stripSome'] : null );
     260        $todaybefore     = $options['todaybefore'];
     261        $adjustImageSize = ( isset( $options['adjustImageSize'] ) ? $options['adjustImageSize'] : null );
     262        $showDesc        = $options['showdesc']; // 1 is show
     263        $descNum         = $options['descnum'];
     264        $maxperPage      = $options['maxperPage'];
     265        $showcategory    = ( isset( $options['showcategory'] ) ? $options['showcategory'] : null );
     266        $maxposts        = $options['maxfeed'];
     267        $showsocial      = $options['showsocial'];
     268        $targetWindow    = $options['targetWindow']; // 0=LB, 1=same, 2=new
     269        $floatType       = $options['floatType'];
     270        $noFollow        = $options['noFollow'];
     271        $showmore        = ( isset( $options['showmore'] ) ? $options['showmore'] : null );
     272        $cb              = ( isset( $options['cb'] ) ? $options['cb'] : null ); // 1 if colorbox should not be loaded
     273        $pag             = $options['pag']; // 1 if pagination 2 or 3 if load more
     274        $perPage         = $options['perPage'];
     275        $addAuthor       = ( isset( $options['addAuthor'] ) ? $options['addAuthor'] : null );
     276        $warnmsg         = ( isset( $options['warnmsg'] ) ? $options['warnmsg'] : null );
     277        $directFetch     = ( isset( $options['directFetch'] ) ? $options['directFetch'] : 0 );
     278        $forceFeed       = ( isset( $options['forceFeed'] ) ? $options['forceFeed'] : false );
     279        $forceFeed       = ( $forceFeed == 1 ? True : False );
     280        $timeout         = ( isset( $options['timeout'] ) ? $options['timeout'] : 10 );
     281        if ( ! isset( $timeout ) ) {
     282            $timeout = 10;
     283        }
     284        if ( ! isset( $directFetch ) ) {
     285            $directFetch = 0;
     286        }
     287        if ( ! is_null( $defaultImage ) ) {
     288            $RSSdefaultImage = $defaultImage;
     289        }
     290        if ( ! is_null( $windowstyle ) ) {
     291            $targetWindow = $windowstyle;
     292        }
     293        if ( ! is_null( $showThisDesc ) ) {
     294            $showDesc = $showThisDesc;
     295        }
     296        if ( ! is_null( $sortOrder ) ) {
     297            $sortDir = $sortOrder;
     298        }
     299        if ( ! is_null( $pshowmore ) ) {
     300            $showmore = $pshowmore;
     301        }
     302        if ( ! is_null( $excerptlength ) ) {
     303            $descNum = $excerptlength;
     304        }
     305        if ( ! is_null( $pnofollow ) ) {
     306            $noFollow = $pnofollow;
     307        }
     308        if ( ! isset( $maxposts ) ) {
     309            $maxposts = 1;
     310        }
     311        if ( empty( $options['sourcename'] ) ) {
     312            $attribution = '';
     313        }
     314        else {
     315            $attribution = $options['sourcename'] . ' ';
     316        }
     317        if ( $parsourcename != '' ) $attribution = $parsourcename;
     318        if ( $floatType == '1' ) {
     319            $float = "left";
     320        }
     321        else {
     322            $float = "none";
     323        }
     324
     325
     326        if ( $parmfloat != '' ) $float = $parmfloat;
     327        if ( $parmmaxperpage != 0 ) $maxperPage = $parmmaxperpage;
     328        if ( $noimage == 1 ) $stripAll = 1;
     329        if ( $thisfeed != '' ) $maxposts = $thisfeed;
     330
     331        if ( $pinterest == 1 ) {
     332            $divfloat = "left";
     333        }
     334        else {
     335            $divfloat = '';
     336        }
     337
     338
     339        if ( is_null( $cb ) && $targetWindow == 0 ) {
     340            add_action( 'wp_footer', 'colorbox_scripts' ); // load colorbox only if not indicated as conflict
     341        }
     342
     343        $template = $options['template'];
     344        if ( $mytemplate != '' ) $template = $mytemplate;
     345
     346
     347//  END PARAMETERS
     348
     349
     350//  GET ALL THE FEEDS   
     351
     352        global $wpdb;
     353        $myarray = array();
     354
     355        /*
     356        if ($thisCat==0){
     357            $feedQuery="SELECT * FROM wp_posts inner join wp_postmeta ON wp_posts.id=wp_postmeta.post_id where `post_type`='rssmi_feed' AND `post_status`='publish' AND `meta_key`='rssmi_url'";
     358        }else{
     359            $feedQuery="SELECT * FROM wp_posts inner join wp_postmeta ON wp_posts.id=wp_postmeta.post_id where `post_type`='rssmi_feed' AND `post_status`='publish' AND `meta_key`='rssmi_cat' AND `meta_value` in ($thisCat) ";
     360            }
     361        */
     362
     363        if ( $thisCat == 0 ) {
     364            $feedQuery = "SELECT * FROM $wpdb->posts as a inner join $wpdb->postmeta as b ON a.id=b.post_id where post_type='rssmi_feed' AND post_status='publish' AND meta_key='rssmi_url'";
     365        }
     366        else {
     367            $feedQuery = "SELECT * FROM $wpdb->posts as a inner join $wpdb->postmeta as b ON a.id=b.post_id where post_type='rssmi_feed' AND post_status='publish' AND meta_key='rssmi_cat' AND meta_value in ($thisCat) ";
     368        }
     369
     370
     371//$feedQuery="SELECT ID FROM $wpdb->posts WHERE  post_type ='rssmi_feed' AND post_status='publish'";
     372
     373        $feed_array = $wpdb->get_results( $feedQuery );
     374
     375        if ( $suppress_warnings == 0 && empty( $feed_array ) ) {
     376
     377            return _e( "There is a problem - it appears you are using categories and no feeds have been put into those categories.", 'wp-rss-multi-importer' );
     378
     379            return;
     380        }
     381
     382
     383//  ****  TAKE EACH FEED AND GET THE ITEMS FROM THAT FEED
     384        foreach ( $feed_array as $feed ) {
     385
     386            $feedlimit      = 0;
     387            $rssmi_cat      = get_post_meta( $feed->ID, 'rssmi_cat', true );
     388            $rssmi_source   = get_the_title( $feed->ID );
     389            $catSourceArray = array(
     390                "myGroup" => $rssmi_source,
     391                "mycatid" => $rssmi_cat
     392            );
     393
     394
     395//  *** SORT THESE DATE AND THEN ADD TO THE FINAL ARRAY
     396
     397//$rssmi_sql = "SELECT a.post_id,b.meta_key,b.meta_value FROM $wpdb->postmeta as a inner join $wpdb->postmeta as b on a.post_id=b.post_id WHERE a.meta_value =$feed->ID and b.meta_key='rssmi_item_date' order by b.meta_value desc";
     398
     399            $rssmi_sql = "SELECT a.post_id,b.meta_key,b.meta_value FROM $wpdb->postmeta as a inner join $wpdb->postmeta as b on a.post_id=b.post_id WHERE a.meta_value =$feed->ID and b.meta_key='rssmi_item_date' order by b.meta_value ";
     400
     401            if ( $sortDir == 0 ) {
     402                $rssmi_sql .= "desc";
     403            }
     404            elseif ( $sortDir == 1 ) {
     405                $rssmi_sql .= "asc";
     406            }
     407
     408
     409            $desc_array = $wpdb->get_results( $rssmi_sql );
     410
     411
     412            foreach ( $desc_array as $arrayItem ) {
     413                $feedlimit = $feedlimit + 1;
     414                if ( $feedlimit > $maxposts ) continue;
     415                $post_ID   = $arrayItem->post_id;
     416                $desc      = get_post_meta( $post_ID, 'rssmi_item_description', true );
     417                $arrayItem = array_merge( (array) $desc[0], $catSourceArray ); //  add the source and category ID
     418                if ( include_post( $rssmi_cat, $arrayItem['mydesc'], $arrayItem['mytitle'] ) == 0 ) {
     419                    continue;
     420                } // FILTER
     421                array_push( $myarray, $arrayItem ); //combine into final array
     422
     423            }
     424
     425        }
     426
     427
     428//  CHECK $myarray BEFORE DOING ANYTHING ELSE //
     429
     430        if ( $dumpthis == 1 ) {
     431            echo "<br><strong>Array</strong><br>";
     432            var_dump( $myarray );
     433            return;
     434        }
     435        if ( ! isset( $myarray ) || empty( $myarray ) ) {
     436            if ( $suppress_warnings == 0 && current_user_can( 'edit_post' ) ) {
     437
     438                return _e( "There is a problem with the feeds you entered. Go to our <a href='http://www.wprssimporter.com/faqs/im-told-the-feed-isnt-valid-or-working/'>support page</a> to see how to solve this.", 'wp-rss-multi-importer' );
     439            }
     440            return;
     441        }
     442
     443        global $isMobileDevice;
     444        if ( isset( $isMobileDevice ) && $isMobileDevice == 1 ) { //open mobile device windows in new tab
     445            $targetWindow = 2;
     446
     447        }
     448
     449
     450//$myarrary sorted by mystrdate
     451
     452        foreach ( $myarray as $key => $row ) {
     453            $dates[$key] = $row["mystrdate"];
     454        }
     455
     456
     457//SORT, DEPENDING ON SETTINGS
     458
     459        if ( $sortDir == 1 ) {
     460            array_multisort( $dates, SORT_ASC, $myarray );
     461        }
     462        elseif ( $sortDir == 0 ) {
     463            array_multisort( $dates, SORT_DESC, $myarray );
     464        }
     465
     466
     467//echo $targetWindow;
     468
     469// HOW THE LINK OPENS
     470
     471        if ( $targetWindow == 0 ) {
     472            $openWindow = 'class="colorbox"';
     473        }
     474        elseif ( $targetWindow == 1 ) {
     475            $openWindow = 'target="_self"';
     476        }
     477        else {
     478            $openWindow = 'target="_blank"';
     479        }
     480
     481        $total      = - 1;
     482        $todayStamp = 0;
     483        $idnum      = rand( 1, 500 );
     484
     485//for pagination
     486        $currentPage = ( isset( $_REQUEST['pg'] ) ? trim( $_REQUEST['pg'] ) : 0 );
     487        $currentURL  = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];
     488        $currentURL  = str_replace( '&pg=' . $currentPage, '', $currentURL );
     489        $currentURL  = str_replace( '?pg=' . $currentPage, '', $currentURL );
     490
     491        if ( strpos( $currentURL, '?' ) == 0 ) {
     492            $currentURL = $currentURL . '?';
     493        }
     494        else {
     495            $currentURL = $currentURL . '&';
     496        }
     497
     498
     499//pagination controls and parameters
     500
     501
     502        if ( ! isset( $perPage ) ) {
     503            $perPage = 5;
     504        }
     505
     506        $numPages = ceil( count( $myarray ) / $perPage );
     507        if ( ! $currentPage || $currentPage > $numPages )
     508            $currentPage = 0;
     509        $start = $currentPage * $perPage;
     510        $end   = ( $currentPage * $perPage ) + $perPage;
     511
     512
     513        if ( $pag == 1 || $pag == 2 || $pag == 3 ) { //set up pagination array and put into myarray
     514            foreach ( $myarray AS $key => $val ) {
     515                if ( $key >= $start && $key < $end )
     516                    $pagedData[] = $myarray[$key];
     517            }
     518
     519            $myarray = $pagedData;
     520        }
     521        //end set up pagination array and put into myarray
     522
     523
     524//  templates checked and added here
     525
     526        if ( ! isset( $template ) || $template == '' ) {
     527            return _e( "One more step...go into the <a href='/wp-admin/options-general.php?page=wp_rss_multi_importer_admin&tab=setting_options'>Settings Panel and choose a Template.</a>", 'wp-rss-multi-importer' );
     528        }
     529
     530
     531        require( WP_RSS_MULTI_TEMPLATES . $template );
     532
     533
     534    }
     535
     536    if ( $pag == 2 || $pag == 3 ) {
     537
     538        add_action( 'rssmi_load_more_data', 'rssmi_pbd_alp_init', 10, 5 );
     539        if ( strpos( $currentURL, 'http' ) == 0 ) {
     540            $nextPost = 'http://' . $currentURL . 'pg=' . ( $currentPage + 1 );
     541        }
     542        else {
     543            $nextPost = $currentURL . 'pg=' . ( $currentPage + 1 );
     544        }
     545        do_action( 'rssmi_load_more_data', $numPages, $currentPage, $nextPost, WP_RSS_MULTI_IMAGES, $pag );
     546    }
     547
     548
     549    //pagination controls at bottom
     550
     551    if ( ( $pag == 1 || $pag == 2 || $pag == 3 ) && $numPages > 1 ) {
     552
     553        $readable .= '<div class="rssmi_pagination"><ul>';
     554
     555        for ( $q = 0; $q < $numPages; $q ++ ) {
     556            //  if($currentPage>0 && $q==0){$readable .='<li class="prev"><a href="http://'.$currentURL.'pg=' . ($currentPage-1) . '">Prev</a></li>';}
     557            if ( $currentPage > 0 && $q == 0 ) {
     558                $readable .= '<li class="prev"><a href="http://' . $currentURL . 'pg=' . ( $currentPage - 1 ) . '">' . __( "Prev", 'wp-rss-multi-importer' ) . '</a></li>';
     559            }
     560
     561            if ( $currentPage <> $q ) {
     562                $readable .= '<li><a href="http://' . $currentURL . 'pg=' . ( $q ) . '"> ' . __( $q + 1, 'wp-rss-multi-importer' ) . '</a></li>';
     563            }
     564            else {
     565                $readable .= '<li class="active"><a href="#">' . ( $q + 1 ) . '</a></li>';
     566            }
     567            if ( $q == $numPages - 1 && $currentPage <> $numPages - 1 ) {
     568                $readable .= '<li class="next"><a href="http://' . $currentURL . 'pg=' . ( $currentPage + 1 ) . '">' . __( "Next", 'wp-rss-multi-importer' ) . '</a></li>';
     569            }
     570        }
     571        $readable .= '</ul></div>';
     572
     573    }
     574    //end pagination controls at bottom
     575
     576
     577    return $readable;
     578
     579
    169580}
    170 add_filter( 'wp_feed_cache_transient_lifetime', 'wprssmi_hourly_feed' );
    171 
    172 
    173    
    174     $siteurl= get_site_url();
    175     $cat_options_url = $siteurl . '/wp-admin/options-general.php?page=wp_rss_multi_importer_admin&tab=category_options/';
    176     $images_url = $siteurl . '/wp-content/plugins/' . basename(dirname(__FILE__)) . '/images'; 
    177    
    178     global $fopenIsSet;
    179     $fopenIsSet = ini_get('allow_url_fopen');
    180    
    181     $parms = shortcode_atts(array(  //Get shortcode parameters
    182         'category' => 0,
    183         'hdsize' => '16px',
    184         'hdweight'=>400,
    185         'anchorcolor' =>'',
    186         'testyle'=>'color: #000000; font-weight: bold;margin: 0 0 0.8125em;',
    187         'maximgwidth'=> 150,
    188         'datestyle'=>'font-style:italic;',
    189         'floattype'=>'',
    190         'showdate' => 1,
    191         'showgroup'=> 1,
    192         'thisfeed'=>'',
    193         'timer' => 0,
    194         'dumpthis' =>0,
    195         'cachetime'=>NULL,
    196         'pinterest'=>0,
    197         'maxperpage' =>0,
    198         'excerptlength'=>NULL,
    199         'noimage' => 0,
    200         'sortorder' => NULL,
    201         'defaultimage' => NULL,
    202         'nofollow'=>NULL,
    203         'showdesc' => NULL,
    204         'mytemplate' =>'',
    205         'showmore'=>NULL,
    206         'sourcename'=>'',
    207         'authorprep'=>'by',
    208         'windowstyle'=>NULL,
    209         'morestyle' =>'[...]'
    210         ), $atts);
    211        
    212     $showThisDesc=$parms['showdesc'];   
    213     $defaultImage=$parms['defaultimage'];
    214     $sortOrder=$parms['sortorder'];
    215     $authorPrep=$parms['authorprep'];
    216     $anchorcolor=$parms['anchorcolor'];
    217     $datestyle=$parms['datestyle'];
    218     $hdsize = $parms['hdsize'];
    219     $thisCat = $parms['category'];
    220     $parmfloat=$parms['floattype'];
    221     $catArray=explode(",",$thisCat);
    222     $showdate=$parms['showdate'];
    223     $showgroup=$parms['showgroup'];
    224     $pshowmore=$parms['showmore'];
    225     $hdweight = $parms['hdweight'];
    226     $testyle = $parms['testyle'];
    227     global $morestyle;
    228     $morestyle = $parms['morestyle'];
    229     global $maximgwidth;
    230     $maximgwidth = $parms['maximgwidth'];
    231     $thisfeed = $parms['thisfeed'];  // max posts per feed
    232     $timerstop = $parms['timer'];
    233     $dumpthis= $parms['dumpthis'];  //diagnostic parameter
    234     $cachename='wprssmi_'.$thisCat;
    235     $cachetime=$parms['cachetime'];
    236     $pnofollow=$parms['nofollow'];
    237     $pinterest=$parms['pinterest'];
    238     $parmmaxperpage=$parms['maxperpage'];
    239     $noimage=$parms['noimage'];
    240     $mytemplate=$parms['mytemplate'];
    241     $windowstyle=$parms['windowstyle'];
    242     $excerptlength=$parms['excerptlength'];
    243     $parsourcename=$parms['sourcename'];
    244     $readable = '';
    245     $options = get_option('rss_import_options','option not found');
    246     $option_items = get_option('rss_import_items','option not found');
    247     $option_category_images = get_option('rss_import_categories_images','option not found');
    248     $rssmi_global_options = get_option( 'rssmi_global_options' );
    249     $suppress_warnings= (isset($rssmi_global_options['suppress_warnings']) ? $rssmi_global_options['suppress_warnings'] : 0);
    250 
    251     if ($option_items==false) return _e("You need to set up the WP RSS Multi Importer Plugin before any results will show here.  Just go into the <a href='/wp-admin/options-general.php?page=wp_rss_multi_importer_admin'>settings panel</a> and put in some RSS feeds", 'wp-rss-multi-importer');
    252 
    253 
    254 
    255 
    256 
    257    
    258    
    259    if(!empty($option_items)){
    260    
    261 //GET PARAMETERS 
    262 global $RSSdefaultImage;
    263 $RSSdefaultImage=$options['RSSdefaultImage'];   // 0- process normally, 1=use default for category, 2=replace when no image available
    264 $size = count($option_items);
    265 $sortDir=$options['sortbydate'];  // 1 is ascending
    266 $stripAll = (isset($options['stripAll']) ? $options['stripAll'] : null);
    267 $stripSome=(isset($options['stripSome']) ? $options['stripSome'] : null);
    268 $todaybefore=$options['todaybefore'];
    269 $adjustImageSize=(isset($options['adjustImageSize']) ? $options['adjustImageSize'] : null);
    270 $showDesc=$options['showdesc'];  // 1 is show
    271 $descNum=$options['descnum'];
    272 $maxperPage=$options['maxperPage'];
    273 $showcategory = (isset($options['showcategory']) ? $options['showcategory'] : null);
    274 $maxposts=$options['maxfeed'];
    275 $showsocial=$options['showsocial'];
    276 $targetWindow=$options['targetWindow'];  // 0=LB, 1=same, 2=new
    277 $floatType=$options['floatType'];
    278 $noFollow=$options['noFollow'];
    279 $showmore = (isset($options['showmore']) ? $options['showmore'] : null);
    280 $cb = (isset($options['cb']) ? $options['cb'] : null); // 1 if colorbox should not be loaded
    281 $pag=$options['pag'];  // 1 if pagination 2 or 3 if load more
    282 $perPage=$options['perPage'];
    283 $addAuthor = (isset($options['addAuthor']) ? $options['addAuthor'] : null);
    284 $warnmsg = (isset($options['warnmsg']) ? $options['warnmsg'] : null);
    285 $directFetch = (isset($options['directFetch']) ? $options['directFetch'] : 0);
    286 $forceFeed = (isset($options['forceFeed']) ? $options['forceFeed'] : false);
    287 $forceFeed= ($forceFeed==1 ? True:False);
    288 $timeout = (isset($options['timeout']) ? $options['timeout'] : 10);
    289 if (!isset($timeout)) {$timeout=10;}
    290 if (!isset($directFetch)) {$directFetch=0;}
    291 if(!is_null($defaultImage)){$RSSdefaultImage=$defaultImage;}
    292 if(!is_null($windowstyle)){$targetWindow=$windowstyle;}
    293 if(!is_null($showThisDesc)){$showDesc=$showThisDesc;}
    294 if(!is_null($sortOrder)){$sortDir=$sortOrder;}
    295 if (!is_null($pshowmore)) {$showmore=$pshowmore;}
    296 if (!is_null($excerptlength)) {$descNum=$excerptlength;}
    297 if (!is_null($pnofollow)) {$noFollow=$pnofollow;}
    298 if(!isset($maxposts)){$maxposts=1;}
    299 if(empty($options['sourcename'])){
    300     $attribution='';
    301 }else{
    302     $attribution=$options['sourcename'].' ';
    303 }
    304 if ($parsourcename!='') $attribution=$parsourcename;
    305 if ($floatType=='1'){
    306     $float="left";
    307 }else{
    308     $float="none"; 
    309 }
    310 
    311 
    312 if ($parmfloat!='') $float=$parmfloat;
    313 if($parmmaxperpage!=0) $maxperPage=$parmmaxperpage;
    314 if ($noimage==1) $stripAll=1;
    315 if ($thisfeed!='') $maxposts=$thisfeed;
    316 
    317 if ($pinterest==1){
    318         $divfloat="left";
    319     }else{
    320         $divfloat='';   
    321     }
    322 
    323 
    324 if (is_null($cb) && $targetWindow==0){
    325         add_action('wp_footer','colorbox_scripts');  // load colorbox only if not indicated as conflict
    326     }
    327 
    328 $template=$options['template'];
    329 if ($mytemplate!='') $template=$mytemplate;
    330 
    331 
    332 
    333 //  END PARAMETERS
    334    
    335    
    336 
    337    
    338    
    339 //  GET ALL THE FEEDS   
    340    
    341 global $wpdb;
    342 $myarray = array();
    343 
    344 /*
    345 if ($thisCat==0){
    346     $feedQuery="SELECT * FROM wp_posts inner join wp_postmeta ON wp_posts.id=wp_postmeta.post_id where `post_type`='rssmi_feed' AND `post_status`='publish' AND `meta_key`='rssmi_url'";
    347 }else{
    348     $feedQuery="SELECT * FROM wp_posts inner join wp_postmeta ON wp_posts.id=wp_postmeta.post_id where `post_type`='rssmi_feed' AND `post_status`='publish' AND `meta_key`='rssmi_cat' AND `meta_value` in ($thisCat) ";
    349     }
    350 */ 
    351    
    352 if ($thisCat==0){
    353     $feedQuery="SELECT * FROM $wpdb->posts as a inner join $wpdb->postmeta as b ON a.id=b.post_id where post_type='rssmi_feed' AND post_status='publish' AND meta_key='rssmi_url'";
    354 }else{
    355     $feedQuery="SELECT * FROM $wpdb->posts as a inner join $wpdb->postmeta as b ON a.id=b.post_id where post_type='rssmi_feed' AND post_status='publish' AND meta_key='rssmi_cat' AND meta_value in ($thisCat) ";
    356     }   
    357    
    358    
    359 
    360 
    361 //$feedQuery="SELECT ID FROM $wpdb->posts WHERE  post_type ='rssmi_feed' AND post_status='publish'";
    362 
    363 $feed_array=$wpdb->get_results($feedQuery);
    364 
    365 if ($suppress_warnings==0 && empty($feed_array)){
    366    
    367     return _e("There is a problem - it appears you are using categories and no feeds have been put into those categories.", 'wp-rss-multi-importer');
    368 
    369     return;
    370 }
    371 
    372 
    373 //  ****  TAKE EACH FEED AND GET THE ITEMS FROM THAT FEED
    374 foreach ($feed_array as $feed){
    375 
    376     $feedlimit=0;
    377     $rssmi_cat= get_post_meta($feed->ID, 'rssmi_cat', true );
    378     $rssmi_source= get_the_title( $feed->ID);
    379     $catSourceArray=array(
    380         "myGroup"=>$rssmi_source,
    381         "mycatid"=>$rssmi_cat
    382     );
    383 
    384 // **   CHECK IF THEY ARE IN THE SELECTED CATEGORIES (FROM THE SETTINGS OR SHORTCODE PARAMETER)
    385 
    386 //if (((!in_array(0, $catArray ) && in_array(intval($rssmi_cat), $catArray ))) || in_array(0, $catArray )) {  //*  not needed if sql query made
    387 
    388 //  *** SORT THESE DATE AND THEN ADD TO THE FINAL ARRAY
    389 
    390 $rssmi_sql = "SELECT a.post_id,b.meta_key,b.meta_value FROM $wpdb->postmeta as a inner join $wpdb->postmeta as b on a.post_id=b.post_id WHERE a.meta_value =$feed->ID and b.meta_key='rssmi_item_date' order by b.meta_value desc";
    391 $desc_array = $wpdb->get_results($rssmi_sql); 
    392 
    393 
    394 
    395 foreach($desc_array as $arrayItem){
    396     $feedlimit=$feedlimit+1; if($feedlimit>$maxposts) continue;
    397     $post_ID=$arrayItem->post_id;
    398     $desc=get_post_meta($post_ID, 'rssmi_item_description', true );
    399     $arrayItem=array_merge ((array)$desc[0],$catSourceArray);  //  add the source and category ID
    400     if(include_post($rssmi_cat,$arrayItem['mydesc'],$arrayItem['mytitle'])==0) {continue;}   // FILTER 
    401     array_push($myarray, $arrayItem);  //combine into final array
    402 
    403     }
    404 //}  //*  not needed if sql query made
    405 }
    406 
    407 
    408 
    409 
    410 
    411 
    412 //  CHECK $myarray BEFORE DOING ANYTHING ELSE //
    413 
    414 if ($dumpthis==1){
    415     echo "<br><strong>Array</strong><br>";
    416     var_dump($myarray);
    417     return;
    418 }
    419 if (!isset($myarray) || empty($myarray)){
    420     if($suppress_warnings==0 && current_user_can('edit_post')){
    421    
    422     return _e("There is a problem with the feeds you entered. Go to our <a href='http://www.wprssimporter.com/faqs/im-told-the-feed-isnt-valid-or-working/'>support page</a> to see how to solve this.", 'wp-rss-multi-importer');
    423     }
    424     return;
    425 }
    426 
    427 global $isMobileDevice;
    428 if (isset($isMobileDevice) && $isMobileDevice==1){  //open mobile device windows in new tab
    429     $targetWindow=2;
    430    
    431     }
    432 
    433 
    434 
    435 
    436 //$myarrary sorted by mystrdate
    437 
    438 foreach ($myarray as $key => $row) {
    439     $dates[$key]  = $row["mystrdate"];
    440 }
    441 
    442 
    443 
    444 //SORT, DEPENDING ON SETTINGS
    445 
    446 if($sortDir==1){
    447     array_multisort($dates, SORT_ASC, $myarray);
    448 }elseif ($sortDir==0){
    449     array_multisort($dates, SORT_DESC, $myarray);       
    450 }
    451 
    452 
    453 
    454 //echo $targetWindow;
    455 
    456 // HOW THE LINK OPENS
    457 
    458 if($targetWindow==0){
    459     $openWindow='class="colorbox"';
    460 }elseif ($targetWindow==1){
    461     $openWindow='target="_self"';   
    462 }else{
    463     $openWindow='target="_blank"'; 
    464 }
    465    
    466 $total = -1;
    467 $todayStamp=0;
    468 $idnum=rand(1, 500);
    469 
    470 //for pagination
    471 $currentPage = (isset($_REQUEST['pg']) ? trim($_REQUEST['pg']): 0);
    472 $currentURL = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];
    473 $currentURL = str_replace( '&pg='.$currentPage, '', $currentURL );
    474 $currentURL = str_replace( '?pg='.$currentPage, '', $currentURL );
    475 
    476 if ( strpos( $currentURL, '?' ) == 0 ){
    477     $currentURL=$currentURL.'?';
    478 }else{
    479     $currentURL=$currentURL.'&';   
    480 }
    481 
    482 
    483 
    484 //pagination controls and parameters
    485 
    486 
    487 if (!isset($perPage)){$perPage=5;}
    488 
    489 $numPages = ceil(count($myarray) / $perPage);
    490 if(!$currentPage || $currentPage > $numPages) 
    491     $currentPage = 0;
    492 $start = $currentPage * $perPage; 
    493 $end = ($currentPage * $perPage) + $perPage;
    494 
    495    
    496         if ($pag==1 || $pag==2 || $pag==3){   //set up pagination array and put into myarray
    497     foreach($myarray AS $key => $val) 
    498         { 
    499         if($key >= $start && $key < $end) 
    500             $pagedData[] = $myarray[$key]; 
    501         }
    502        
    503             $myarray=$pagedData;
    504     }
    505       //end set up pagination array and put into myarray
    506 
    507 
    508 
    509    
    510 //  templates checked and added here
    511 
    512     if (!isset($template) || $template=='') {
    513     return _e("One more step...go into the <a href='/wp-admin/options-general.php?page=wp_rss_multi_importer_admin&tab=setting_options'>Settings Panel and choose a Template.</a>", 'wp-rss-multi-importer');
    514     }
    515    
    516 
    517     require( WP_RSS_MULTI_TEMPLATES . $template );
    518 
    519    
    520 
    521 
    522 }
    523 
    524 if ($pag==2 || $pag==3){
    525          
    526 add_action('rssmi_load_more_data', 'rssmi_pbd_alp_init',10,5);
    527 if (strpos($currentURL,'http')==0){
    528 $nextPost='http://'.$currentURL.'pg=' . ($currentPage+1);
    529 }else{
    530 $nextPost=$currentURL.'pg=' . ($currentPage+1);
    531 }
    532 do_action('rssmi_load_more_data',$numPages,$currentPage,$nextPost,WP_RSS_MULTI_IMAGES,$pag);
    533 }
    534 
    535 
    536 
    537     //pagination controls at bottom
    538    
    539         if (($pag==1 || $pag==2 || $pag==3) && $numPages>1){
    540 
    541             $readable .='<div class="rssmi_pagination"><ul>';
    542        
    543         for($q=0;$q<$numPages;$q++){
    544         //  if($currentPage>0 && $q==0){$readable .='<li class="prev"><a href="http://'.$currentURL.'pg=' . ($currentPage-1) . '">Prev</a></li>';}
    545             if($currentPage>0 && $q==0){$readable .='<li class="prev"><a href="http://'.$currentURL.'pg=' . ($currentPage-1) . '">'.__("Prev", 'wp-rss-multi-importer').'</a></li>';}
    546            
    547             if($currentPage<>$q){
    548                 $readable .= '<li><a href="http://'.$currentURL.'pg=' . ($q) . '"> '.__($q+1, 'wp-rss-multi-importer').'</a></li>'; 
    549             }else{
    550                 $readable .='<li class="active"><a href="#">'.($q+1).'</a></li>';
    551             }
    552         if( $q==$numPages-1 && $currentPage<>$numPages-1){$readable .='<li class="next"><a href="http://'.$currentURL.'pg=' . ($currentPage+1) . '">'.__("Next", 'wp-rss-multi-importer').'</a></li>';}
    553         }
    554             $readable .='</ul></div>';
    555        
    556     }
    557      //end pagination controls at bottom
    558    
    559 
    560 return $readable;
    561 
    562 
    563 
    564    }
    565    
    566 
    567    
    568    
     581
     582
    569583?>
Note: See TracChangeset for help on using the changeset viewer.