コード例 #1
0
 function test_extract_excluded_site_bad_regexp()
 {
     update_option('amber_options', array('amber_excluded_sites' => "*yahoo.com"));
     $this->checker_stub->method('check')->willReturn(array('status' => 1));
     $post_id = $this->factory->post->create(array('post_content' => 'The quick brown <a href="http://yahoo.com/">fox</a> jumped over the lazy <a href="http://dog.com/yahoo.com">dog</a>'));
     /* This will emit warning messages, but they can be ignored */
     $result = Amber::extract_links($post_id, true);
     $this->assertEquals(2, count($result));
     $this->assertEquals(1, $result["http://yahoo.com/"]);
     $this->assertEquals(1, $result["http://dog.com/yahoo.com"]);
 }
コード例 #2
0
ファイル: amber.php プロジェクト: su/amber_wordpress
 public static function ajax_scan()
 {
     /* Maximum number of pages and posts to process in each 
        request. This is used for both pages AND posts, so the
        maximum per request is actually twice this, depending
        on the mix of content on the site */
     check_ajax_referer('amber_dashboard');
     $batch_size = 10;
     $number_remaining = 0;
     $transients = array('amber_scan_pages', 'amber_scan_posts');
     foreach ($transients as $t) {
         $ids = get_transient($t);
         if ($ids !== FALSE && is_array($ids)) {
             $i = $batch_size;
             while (count($ids) > 0 && $i-- > 0) {
                 $id = array_shift($ids);
                 Amber::extract_links($id);
             }
             set_transient($t, $ids, 24 * 60 * 60);
             $number_remaining += count($ids);
         }
     }
     print $number_remaining;
     die;
 }