Пример #1
0
function tdomf_overview_menu()
{
    global $wpdb, $wp_roles;
    // Initilise the plugin for the first time here. This gets called when you click the TDOMF button in the menu.
    // Doing it here means you can delete all the options!
    tdomf_init();
    // get feed_messages
    require_once ABSPATH . WPINC . '/rss.php';
    if (!isset($wp_roles)) {
        $wp_roles = new WP_Roles();
    }
    $roles = $wp_roles->role_objects;
    ?>
  <div class="wrap">
    <h2><?php 
    _e('Welcome to TDO Mini Forms', 'tdomf');
    ?>
</h2>

    <div id="zeitgeist">

        <?php 
    $features = tdomf_new_features();
    if ($features) {
        ?>
                <h2><?php 
        printf(__("New Features in %s for you", "tdomf"), TDOMF_VERSION);
        ?>
</h2>
                <?php 
        echo $features;
        ?>
        <?php 
    }
    ?>
    
    	  <h2><?php 
    _e('Latest Activity', 'tdomf');
    ?>
</h2>
        
    	  <h3><?php 
    _e('Log', 'tdomf');
    if (current_user_can('manage_options')) {
        ?>
<a href="admin.php?page=tdomf_show_log_menu" title="Full Log...">&raquo;</a><?php 
    }
    ?>
</h3>

    	  <p><?php 
    echo tdomf_get_log(5);
    ?>
</p>

        <?php 
    if (tdomf_is_moderation_in_use()) {
        ?>

          <?php 
        $posts = tdomf_get_unmoderated_posts(0, 10);
        if (!empty($posts)) {
            ?>
            
        	  <h3><?php 
            _e('Latest Submissions', 'tdomf');
            if (current_user_can('edit_others_posts')) {
                ?>
<a href="admin.php?page=tdomf_show_mod_posts_menu&f=0" title="<?php 
                _e("Moderate Submissions...", "tdomf");
                ?>
">&raquo;</a><?php 
            }
            ?>
</h3>

          <ul>

              
                <?php 
            foreach ($posts as $p) {
                echo tdomf_get_post_list_line($p);
            }
        }
        ?>
    	  </ul>

    	  <?php 
    }
    ?>

          <?php 
    if (get_option(TDOMF_OPTION_SPAM)) {
        ?>
              <?php 
        $spam_count = tdomf_get_spam_posts_count();
        if ($spam_count > 0) {
            ?>
                  <h3><?php 
            printf(__('There are %d spam submissions', 'tdomf'), $spam_count);
            if (current_user_can('edit_others_posts')) {
                ?>
<a href="admin.php?page=tdomf_show_mod_posts_menu&f=3" title="<?php 
                _e("Moderate Spam...", "tdomf");
                ?>
">&raquo;</a><?php 
            }
            ?>
</h3>
              <?php 
        }
        ?>
          <?php 
    }
    ?>
          
          <?php 
    $posts = tdomf_get_published_posts(0, 10);
    if (!empty($posts)) {
        ?>

    	  <h3><?php 
        _e('Latest Approved Submissions', 'tdomf');
        if (current_user_can('edit_others_posts')) {
            ?>
<a href="admin.php?page=tdomf_show_mod_posts_menu&f=1" title="Moderate Posts...">&raquo;</a><?php 
        }
        ?>
</h3>

    	  <ul>
                  
                  
              <?php 
        foreach ($posts as $p) {
            echo tdomf_get_post_list_line($p);
        }
    }
    ?>
    	  </ul>

          

    	  <h3><?php 
    _e('Stats', 'tdomf');
    ?>
</h3>

          <?php 
    $stat_sub_ever = get_option(TDOMF_STAT_SUBMITTED);
    $stat_edit_ever = get_option(TDOMF_STAT_EDITED);
    $stat_unmod = tdomf_get_unmoderated_posts_count();
    $stat_edit_unmod = tdomf_get_edits(array('state' => 'unapproved', 'count' => true, 'unique_post_ids' => true));
    $stat_sub_cur = tdomf_get_submitted_posts_count();
    $stat_edit_cur = tdomf_get_edits(array('count' => true, 'unique_post_ids' => true));
    $stat_mod = $stat_sub_cur - $stat_unmod;
    $stat_edit_mod = tdomf_get_edits(array('state' => 'approved', 'count' => true, 'unique_post_ids' => true));
    $stat_spam = get_option(TDOMF_STAT_SPAM);
    ?>

          <?php 
    if (get_option(TDOMF_OPTION_SPAM)) {
        ?>
              <p><?php 
        printf(__("You are using version %s (build %d) of the TDO Mini Forms plugin. There has been %d posts (or pages) submitted, %d edits submitted, %d posts approved and %d edits approved. %d spam submissions have been caught by Akismet", "tdomf"), TDOMF_VERSION, get_option(TDOMF_VERSION_CURRENT), $stat_sub_ever, $stat_edit_ever, $stat_mod, $stat_edit_mod, $stat_spam);
        ?>
          <?php 
    } else {
        ?>
              <p><?php 
        printf(__("You are using version %s (build %d) of the TDO Mini Forms plugin. There has been %d posts (or pages) submitted, %d edits submitted, %d posts approved and %d edits approved.", "tdomf"), TDOMF_VERSION, get_option(TDOMF_VERSION_CURRENT), $stat_sub_ever, $stat_edit_ever, $stat_mod, $stat_edit_mod);
        ?>
          <?php 
    }
    ?>
        
        <?php 
    $rss = fetch_rss('http://thedeadone.net/forum/?cat=6&feed=rss');
    if (isset($rss->items) && 0 != count($rss->items)) {
        $rss->items = array_slice($rss->items, 0, 5);
        echo "<h3>" . __('Latest Support Forum Topics', 'tdomf') . "</h3><ul>";
        foreach ($rss->items as $item) {
            ?>
                 <li><a href='<?php 
            echo wp_filter_kses($item['link']);
            ?>
'><?php 
            echo wp_specialchars($item['title']);
            ?>
</a></li>
        <?php 
        }
        echo "</ul>";
    }
    ?>
        
    </div>

    <?php 
    echo "<p>" . ($message = tdomf_get_error_messages() . "</p>");
    ?>

    <table style="margin:0px;padding:0px">
      <tr>
        <td>
          <form action="https://www.paypal.com/cgi-bin/webscr" method="post" >
          <input type="hidden" name="cmd" value="_s-xclick">
          <input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but21.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!" style="border:0px;" >
          <img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
          <input type="hidden" name="encrypted" value="-----BEGIN PKCS7-----MIIIWQYJKoZIhvcNAQcEoIIISjCCCEYCAQExggEwMIIBLAIBADCBlDCBjjELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtQYXlQYWwgSW5jLjETMBEGA1UECxQKbGl2ZV9jZXJ0czERMA8GA1UEAxQIbGl2ZV9hcGkxHDAaBgkqhkiG9w0BCQEWDXJlQHBheXBhbC5jb20CAQAwDQYJKoZIhvcNAQEBBQAEgYBuEC47mJwumB8/XIQIyehLoyT5ueMyjGzjeTnWxYcjdY3rAgkJteuOvqnnYNG7R8x9g2NVIJYHleMRt7O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jb20CAQAwCQYFKw4DAhoFAKBdMBgGCSqGSIb3DQEJAzELBgkqhkiG9w0BBwEwHAYJKoZIhvcNAQkFMQ8XDTA3MDkyNjE0MzQwM1owIwYJKoZIhvcNAQkEMRYEFClTuUrBDEQ7H6sAZIN8yB9qKifJMA0GCSqGSIb3DQEBAQUABIGAGr+klEj8FgUscdaxj/kalFxvuQnSznQDFmsPvJZfwa7Wur3EnF75m7+qvQOeFSZ56a3aXjSELI9ej1vXXz8mjZqUQYEeFLqvulKl3KVHS32KprXTj5iqp3TapPbeoSsMggxVxJ1HjmakNJm3UwhqlEIoc0qjf1wHPIIWSBJcAug=-----END PKCS7-----
">
          </form>
        </td><td>
          <?php 
    printf(__("[<a href='%s'>My Amazon Wishlist</a>]", "tdomf"), "http://www.amazon.co.uk/gp/registry/23S7OL9W6Q4JT");
    ?>
        </td>
        <td>
          <?php 
    printf(__("[<a href='%s'>Rate TDO-Mini-Forms on Wordpress.org!</a>]", "tdomf"), "http://wordpress.org/extend/plugins/tdo-mini-forms/#rate-response");
    ?>
        </td>
      </tr>
    </table>
    
    <p><?php 
    _e("Use these links to get started:", "tdomf");
    ?>
</p>

    <ul>
      <li><a href="admin.php?page=tdomf_show_options_menu"><?php 
    _e("Configure TDO Mini Forms", "tdomf");
    ?>
</a></li>
      <li><a href="admin.php?page=tdomf_show_form_menu"><?php 
    _e("Form Widgets", "tdomf");
    ?>
</a></li>
      <?php 
    if (get_option(TDOMF_OPTION_YOUR_SUBMISSIONS)) {
        ?>
          <?php 
        if (current_user_can('edit_users')) {
            ?>
                <li><a href="users.php?page=tdomf_your_submissions"><?php 
            _e("Your Submissions Page", "tdomf");
            ?>
</a></li>
          <?php 
        } else {
            ?>
                <li><a href="profile.php?page=tdomf_your_submissions"><?php 
            _e("Your Submissions Page", "tdomf");
            ?>
</a></li>
          <?php 
        }
        ?>
      <?php 
    }
    ?>
      <?php 
    if (current_user_can('manage_options')) {
        ?>
      <li><a href="<?php 
        echo TDOMF_URLPATH;
        ?>
tdomf-phpinfo.php"><?php 
        _e("phpinfo()", "tdomf");
        ?>
</a></li>
      <li><a href="admin.php?page=<?php 
        echo TDOMF_FOLDER . DIRECTORY_SEPARATOR . "admin" . DIRECTORY_SEPARATOR;
        ?>
tdomf-info.php"><?php 
        _e("tdomfinfo()", "tdomf");
        ?>
</a></li>
      <?php 
    }
    ?>
    </ul>

<p><?php 
    _e('Need help with TDO Mini Forms? Please see the <a href="http://thedeadone.net/forum">support forums on thedeadone.net</a> or the <a href="http://wordpress.org/tags/tdo-mini-forms">support forums on wordpress.org</a>.', "tdomf");
    ?>
</p>

    <h3><?php 
    _e('Welcome', 'tdomf');
    ?>
</h3>

    <p>
    <?php 
    _e("TDO Mini Forms plugin allows you to provide a form to your readers and users so that they can submit posts to your blog, even if they don't have rights to do so. You can control what type of users, such as unregistered users and subscribers, can access and use the form. Posts are submitted as draft so that you can approve them before they are published. (You can optionally turn this off so that submissions are automatically published). As of version 0.7, you can now also customise the form using widgets.", "tdomf");
    ?>
    </p>
        
    <div id="devnews">
    <h3><?php 
    _e('Latest TDO Mini Forms News!', 'tdomf');
    ?>
</h3>

    <?php 
    $rss = fetch_rss('http://thedeadone.net/tag/tdomf/feed');
    if (isset($rss->items) && 0 != count($rss->items)) {
        $rss->items = array_slice($rss->items, 0, 4);
        foreach ($rss->items as $item) {
            ?>
          <h4><a href='<?php 
            echo wp_filter_kses($item['link']);
            ?>
'><?php 
            echo wp_specialchars($item['title']);
            ?>
</a> &#8212; <?php 
            echo human_time_diff(strtotime($item['pubdate'], time()));
            ?>
</h4>
          <p><?php 
            echo '<strong>' . date("F, jS", strtotime($item['pubdate'])) . '</strong> - ' . $item['description'];
            ?>
</p>
        <?php 
        }
    } else {
        ?>
        <p><?php 
        printf(__('Newsfeed could not be loaded.  Check the <a href="%s">thedeadone.net</a> to check for updates.', 'tdomf'), 'http://thedeadone.net/index.php?tag=tdomf');
        ?>
</p>
        <?php 
    }
    ?>
    </div>
    <br style="clear: both" />
   </div>
    <?php 
}
Пример #2
0
 function tdomf_theme_widget_submitters($args)
 {
     extract($args);
     $options = get_option('tdomf_theme_widget_submitters');
     $title = 'Top Submitters';
     $count = 5;
     $use_subs = true;
     $use_reg = true;
     $use_link = false;
     $avatar = false;
     $avatar_size = 25;
     $avatar_default = "";
     if ($options != false) {
         $title = $options['title'];
         $count = $options['count'];
         $use_subs = $options['use_subs'];
         $use_reg = $options['use_reg'];
         $use_link = $options['use_link'];
         if (isset($options['avatar'])) {
             $avatar = $options['avatar'];
             $avatar_size = $options['avatar_size'];
             $avatar_default = $options['avatar_default'];
         }
     }
     $posts = tdomf_get_published_posts();
     $users = array();
     $subs = array();
     foreach ($posts as $p) {
         if ($user_id = get_post_meta($p->ID, TDOMF_KEY_USER_ID, true)) {
             if ($use_reg) {
                 if (get_usermeta($user_id, TDOMF_KEY_STATUS) != TDOMF_USER_STATUS_BANNED) {
                     $user = get_userdata($user_id);
                     if (isset($user)) {
                         $id = intval($user_id);
                         if (!isset($users[$id])) {
                             $u = array();
                             $u['web'] = trim($user->user_url);
                             if (strlen($u['web']) < 8 || strpos($u['web'], "http://", 0) !== 0) {
                                 $u['web'] = false;
                             }
                             if (function_exists('get_avatar')) {
                                 $u['avatar'] = get_avatar($id, $avatar_size, $avatar_default);
                             }
                             $u['name'] = $user->display_name;
                             $u['link'] = get_author_posts_url($user_id);
                             $u['count'] = 1;
                             $users[$id] = $u;
                         } else {
                             $users[$id]['count']++;
                         }
                     }
                 }
             }
         } else {
             if ($use_subs) {
                 // all theses are optional, but in terms of priority:
                 // 1. email, 2. name, 3. web (but not that both name and web can be
                 // faked by another submitter
                 $sub = array();
                 $sub['count'] = 1;
                 $sub['email'] = false;
                 $sub['avatar'] = "";
                 if (get_post_meta($p->ID, TDOMF_KEY_EMAIL)) {
                     // use lowercase to avoid case-sensitive misses
                     $sub['email'] = strtolower(trim(get_post_meta($p->ID, TDOMF_KEY_EMAIL, true)));
                     if (function_exists('get_avatar')) {
                         $sub['avatar'] = get_avatar($sub['email'], $avatar_size, $avatar_default);
                     }
                 }
                 $sub['name'] = false;
                 if (get_post_meta($p->ID, TDOMF_KEY_NAME)) {
                     // keep case
                     $sub['name'] = trim(get_post_meta($p->ID, TDOMF_KEY_NAME, true));
                 }
                 $sub['web'] = false;
                 if (get_post_meta($p->ID, TDOMF_KEY_WEB)) {
                     // use lowercase to avoid case-sensitive misses
                     $sub['web'] = strtolower(get_post_meta($p->ID, TDOMF_KEY_WEB, true));
                 }
                 $hit = false;
                 foreach ($subs as $s) {
                     if ($sub['email'] != false && $s['email'] != false && $s['email'] == $sub['email']) {
                         // we scored a hit
                         $s['name'] = $sub['name'];
                         $s['web'] = $sub['web'];
                         $s['count']++;
                         $hit = true;
                         break;
                     }
                     if ($sub['name'] != false && $s['name'] != false && $s['name'] == $sub['name']) {
                         // we scored a hit
                         // no email set so this looks good!
                         if ($s['email'] == false && $sub['email'] == false) {
                             $s['web'] = $sub['web'];
                             $s['count']++;
                         }
                         $hit = true;
                         break;
                     }
                     if ($sub['web'] != false && $s['web'] != false && $s['web'] == $sub['web']) {
                         // we scored a hit
                         // no email set so this looks good!
                         if ($s['email'] == false && $sub['email'] == false && $s['name'] == false && $sub['name'] == false) {
                             $s['count']++;
                         }
                         $hit = true;
                         break;
                     }
                 }
                 if (!$hit) {
                     $subs[] = $sub;
                 }
             }
         }
     }
     $list = array();
     if (!empty($users) && !empty($subs)) {
         $list = array_merge($users, $subs);
     } else {
         if (!empty($users)) {
             $list = $users;
         } else {
             if (!empty($subs)) {
                 $list = $subs;
             }
         }
     }
     if (!empty($list)) {
         if (!function_exists("tdomf_theme_widget_submitters_cmp")) {
             function tdomf_theme_widget_submitters_cmp($a, $b)
             {
                 if ($a['count'] == $b['count']) {
                     return 0;
                 }
                 return $a['count'] > $b['count'] ? -1 : +1;
             }
         }
         usort($list, "tdomf_theme_widget_submitters_cmp");
         $list = array_slice($list, 0, $count);
     }
     if (!empty($list)) {
         echo $before_widget;
         if ($title) {
             echo $before_title;
             echo $title;
             echo $after_title;
         }
         echo "<ul>";
         foreach ($list as $l) {
             echo "<li>";
             if ($use_link) {
                 if (isset($l['link'])) {
                     echo "<a href=\"" . $l['link'] . "\">";
                 } else {
                     if ($l['web'] != false) {
                         echo "<a href=\"" . $l['web'] . "\">";
                     }
                 }
             } else {
                 if ($l['web'] != false) {
                     echo "<a href=\"" . $l['web'] . "\">";
                 } else {
                     if (isset($l['link'])) {
                         echo "<a href=\"" . $l['link'] . "\">";
                     }
                 }
             }
             if ($avatar && isset($l['avatar'])) {
                 echo " " . $l['avatar'] . " ";
             }
             echo $l['name'] . " (" . $l['count'] . ")";
             if (isset($l['link']) || $l['web'] != false) {
                 echo "</a>";
             }
             echo "</li>";
         }
         echo "</ul>";
         echo $after_widget;
     }
 }