Пример #1
0
 function check($php_files, $css_files, $other_files)
 {
     $ret = true;
     checkcount();
     $checks = array('[ \\t\\/*#]@version' => '@version');
     foreach ($php_files as $php_key => $phpfile) {
         // leave out functions.php as this is a special case
         if (tc_filename($php_key) == 'functions.php') {
             continue;
         }
         foreach ($checks as $key => $check) {
             // We don't need to write to the file, so just open for reading.
             // This is needed, because comments are stripped out in the main plugin
             $fp = fopen($php_key, 'r');
             // Pull only the first 8kiB of the file in.
             $file_data = fread($fp, 8192);
             // PHP will close file handle, but we are good citizens. :)
             fclose($fp);
             // Make sure we catch CR-only line endings.
             $file_data = str_replace("\r", "\n", $file_data);
             if (!preg_match('/' . $key . '/i', $file_data, $matches)) {
                 //$filename = tc_filename( $php_key );
                 $filename = self::tc_templatepath($php_key);
                 // Point out the missing line.
                 $error_msg = sprintf(__('%1$s is missing in the file %2$s.', 'theme-check'), '<strong>' . $check . '</strong>', '<strong>' . $filename . '</strong>');
                 // Add the finalized error message.
                 $this->error[] = '<span class="tc-lead tc-recommended">' . __('RECOMMENDED', 'theme-check') . '</span>: ' . $error_msg;
             }
         }
     }
     return $ret;
 }
Пример #2
0
 function check($php_files, $css_files, $other_files)
 {
     $ret = true;
     //check for levels deprecated in 2.0 in creating menus.
     $checks = array('/([^_](add_(admin|submenu|menu|dashboard|posts|media|links|pages|comments|theme|plugins|users|management|options)_page)\\s?\\([^,]*,[^,]*,\\s[\'|"]?(level_[0-9]|[0-9])[^;|\\r|\\r\\n]*)/' => __('User levels were deprecated in <strong>2.0</strong>. Please see <a href="https://codex.wordpress.org/Roles_and_Capabilities">Roles_and_Capabilities</a>', 'theme-check'), '/[^a-z0-9](current_user_can\\s?\\(\\s?[\'\\"]level_[0-9][\'\\"]\\s?\\))[^\\r|\\r\\n]*/' => __('User levels were deprecated in <strong>2.0</strong>. Please see <a href="https://codex.wordpress.org/Roles_and_Capabilities">Roles_and_Capabilities</a>', 'theme-check'));
     foreach ($php_files as $php_key => $phpfile) {
         foreach ($checks as $key => $check) {
             checkcount();
             if (preg_match($key, $phpfile, $matches)) {
                 $filename = tc_filename($php_key);
                 $grep = isset($matches[2]) ? tc_grep($matches[2], $php_key) : tc_grep($matches[1], $php_key);
                 $this->error[] = sprintf('<span class="tc-lead tc-warning">' . __('WARNING', 'theme-check') . '</span>: <strong>%1$s</strong>. %2$s%3$s', $filename, $check, $grep);
                 $ret = false;
             }
         }
     }
     //check for add_admin_page
     $checks = array('/([^_]add_(admin|submenu|menu|dashboard|posts|media|links|pages|comments|plugins|users|management|options)_page)/' => __('Themes should use <strong>add_theme_page()</strong> for adding admin pages.', 'theme-check'));
     foreach ($php_files as $php_key => $phpfile) {
         foreach ($checks as $key => $check) {
             checkcount();
             if (preg_match($key, $phpfile, $matches)) {
                 $filename = tc_filename($php_key);
                 $error = ltrim(rtrim($matches[0], '('));
                 $grep = tc_grep($error, $php_key);
                 $this->error[] = sprintf('<span class="tc-lead tc-required">' . __('REQUIRED', 'theme-check') . '</span>: <strong>%1$s</strong>. %2$s%3$s', $filename, $check, $grep);
                 $ret = false;
             }
         }
     }
     return $ret;
 }
Пример #3
0
 function check($php_files, $css_files, $other_files)
 {
     $ret = true;
     $filenames = array();
     foreach ($other_files as $other_key => $otherfile) {
         array_push($filenames, strtolower(basename($other_key)));
     }
     checkcount();
     if (in_array('screenshot.png', $filenames) || in_array('screenshot.jpg', $filenames)) {
         foreach ($other_files as $other_key => $otherfile) {
             if ((basename($other_key) === 'screenshot.png' || basename($other_key) === 'screenshot.jpg') && preg_match('/.*themes\\/[^\\/]*\\/screenshot\\.(png|jpg)/', $other_key)) {
                 // we have or screenshot!
                 $image = getimagesize($other_key);
                 if ($image[0] > 1200 || $image[1] > 900) {
                     $this->error[] = sprintf('<span class="tc-lead tc-recommended">' . __('RECOMMENDED', 'theme-check') . '</span>: ' . __('Screenshot is wrong size! Detected: <strong>%1$sx%2$spx</strong>. Maximum allowed size is 1200x800px.', 'theme-check'), $image[0], $image[1]);
                 }
                 if ($image[1] / $image[0] != 0.75) {
                     $this->error[] = '<span class="tc-lead tc-recommended">' . __('RECOMMENDED', 'theme-check') . '</span>: ' . __('Screenshot dimensions are wrong! Ratio of width to height should be 4:3.', 'theme-check');
                 }
                 if ($image[0] != 1200 || $image[1] != 900) {
                     $this->error[] = '<span class="tc-lead tc-recommended">' . __('RECOMMENDED', 'theme-check') . '</span>: ' . __('Screenshot size should be 880x660, to account for HiDPI displays. Any 4:3 image size is acceptable, but 1200x900 is preferred.', 'theme-check');
                 }
             }
         }
     } else {
         $this->error[] = '<span class="tc-lead tc-warning">' . __('WARNING', 'theme-check') . '</span>: ' . __('No screenshot detected! Please include a screenshot.png or screenshot.jpg.', 'theme-check');
         $ret = false;
     }
     return $ret;
 }
Пример #4
0
 function check($php_files, $css_files, $other_files)
 {
     $grep = '';
     $ret = true;
     $checks = array(array('preview_theme' => '', '4.3'), array('_preview_theme_template_filter' => '', '4.3'), array('_preview_theme_stylesheet_filter' => '', '4.3'), array('preview_theme_ob_filter' => '', '4.3'), array('preview_theme_ob_filter_callback' => '', '4.3'), array('wp_richedit_pre' => '', '4.3'), array('wp_htmledit_pre' => '', '4.3'), array('wp_ajax_wp_fullscreen_save_post' => '', '4.3'), array('post_permalink' => 'get_permalink', '4.4'), array('wp_get_http' => 'WP_Http', '4.4'), array('force_ssl_login' => 'force_ssl_admin', '4.4'), array('create_empty_blog' => '', '4.4'), array('get_admin_users_for_domain' => '', '4.4'), array('flush_widget_cache' => '', '4.4'));
     foreach ($php_files as $php_key => $phpfile) {
         foreach ($checks as $alt => $check) {
             checkcount();
             $version = $check;
             $key = key($check);
             $alt = $check[$key];
             if (preg_match('/[\\s?]' . $key . '\\(/', $phpfile, $matches)) {
                 $filename = tc_filename($php_key);
                 $error = ltrim(rtrim($matches[0], '('));
                 $version = $check[0];
                 $grep = tc_grep($error, $php_key);
                 // Point out the deprecated function.
                 $error_msg = sprintf(__('%1$s found in the file %2$s. Deprecated since version %3$s.', 'theme-check'), '<strong>' . $error . '()</strong>', '<strong>' . $filename . '</strong>', '<strong>' . $version . '</strong>');
                 // Add alternative function when available.
                 if ($alt) {
                     $error_msg .= ' ' . sprintf(__('Use %s instead.', 'theme-check'), '<strong>' . $alt . '</strong>');
                 }
                 // Add the precise code match that was found.
                 $error_msg .= $grep;
                 // Add the finalized error message.
                 $this->error[] = '<span class="tc-lead tc-recommended">' . __('RECOMMENDED', 'theme-check') . '</span>: ' . $error_msg;
             }
         }
     }
     return $ret;
 }
Пример #5
0
 function check($php_files, $css_files, $other_files)
 {
     $ret = true;
     $found = false;
     foreach ($php_files as $name => $file) {
         checkcount();
         if (strpos($name, '.git') !== false || strpos($name, '.svn') !== false) {
             $found = true;
         }
     }
     foreach ($css_files as $name => $file) {
         checkcount();
         if (strpos($name, '.git') !== false || strpos($name, '.svn') !== false || strpos($name, '.hg') !== false || strpos($name, '.bzr') !== false) {
             $found = true;
         }
     }
     foreach ($other_files as $name => $file) {
         checkcount();
         if (strpos($name, '.git') !== false || strpos($name, '.svn') !== false || strpos($name, '.hg') !== false || strpos($name, '.bzr') !== false) {
             $found = true;
         }
     }
     if ($found) {
         $this->error[] = sprintf('<span class="tc-lead tc-required">' . __('REQUIRED', 'theme-check') . '</span>: ' . __('Please remove any extraneous directories like .git or .svn from the ZIP file before uploading it.', 'theme-check'));
         $ret = false;
     }
     return $ret;
 }
Пример #6
0
 function check($php_files, $css_files, $other_files)
 {
     $ret = true;
     $filenames = array();
     foreach ($other_files as $other_key => $otherfile) {
         array_push($filenames, strtolower(basename($other_key)));
     }
     checkcount();
     if (in_array('screenshot.png', $filenames)) {
         foreach ($other_files as $other_key => $otherfile) {
             if (basename($other_key) === 'screenshot.png' && preg_match('/.*themes\\/[^\\/]*\\/screenshot\\.png/', $other_key)) {
                 // we have or screenshot!
                 $image = getimagesize($other_key);
                 if ($image[0] > 640 || $image[1] > 480) {
                     $this->error[] = sprintf(__('<span class="tc-lead tc-recommended">RECOMMENDED</span>: Screenshot is wrong size! Detected: <strong>%1$sx%2$spx</strong>. Maximum allowed size is 640x480px.', 'themecheck'), $image[0], $image[1]);
                 }
                 if ($image[1] / $image[0] != 0.75) {
                     $this->error[] = __('<span class="tc-lead tc-recommended">RECOMMENDED</span>: Screenshot dimensions are wrong! Ratio of width to height should be 4:3.', 'themecheck');
                 }
                 if ($image[0] != 600 || $image[1] != 450) {
                     $this->error[] = __('<span class="tc-lead tc-recommended">RECOMMENDED</span>: Screenshot size should be 600x450, to account for HiDPI displays. Any 4:3 image size is acceptable, but 600x450 is preferred.', 'themecheck');
                 }
             }
         }
     } else {
         $this->error[] = __("<span class='tc-lead tc-warning'>WARNING</span>: No screenshot detected! Please include a screenshot.png.", "themecheck");
         $ret = false;
     }
     return $ret;
 }
Пример #7
0
 function check($php_files, $css_files, $other_files)
 {
     $grep = '';
     $ret = true;
     $checks = array(array('rich_edit_exists' => '', '3.9'), array('default_topic_count_text' => '', '3.9'), array('format_to_post' => '', '3.9'), array('get_current_site_name' => 'get_current_site()', '3.9'), array('wpmu_current_site' => '', '3.9'), array('get_all_category_ids' => 'get_terms()', '4.0'), array('like_escape' => 'wpdb::esc_like()', '4.0'), array('url_is_accessable_via_ssl' => '', '4.0'));
     foreach ($php_files as $php_key => $phpfile) {
         foreach ($checks as $alt => $check) {
             checkcount();
             $version = $check;
             $key = key($check);
             $alt = $check[$key];
             if (preg_match('/[\\s?]' . $key . '\\(/', $phpfile, $matches)) {
                 $filename = tc_filename($php_key);
                 $error = ltrim(rtrim($matches[0], '('));
                 $version = $check[0];
                 $grep = tc_grep($error, $php_key);
                 // Point out the deprecated function.
                 $error_msg = sprintf(__('%1$s found in the file %2$s. Deprecated since version %3$s.', 'theme-check'), '<strong>' . $error . '()</strong>', '<strong>' . $filename . '</strong>', '<strong>' . $version . '</strong>');
                 // Add alternative function when available.
                 if ($alt) {
                     $error_msg .= ' ' . sprintf(__('Use %s instead.', 'theme-check'), '<strong>' . $alt . '</strong>');
                 }
                 // Add the precise code match that was found.
                 $error_msg .= $grep;
                 // Add the finalized error message.
                 $this->error[] = '<span class="tc-lead tc-recommended">' . __('RECOMMENDED', 'theme-check') . '</span>: ' . $error_msg;
             }
         }
     }
     return $ret;
 }
Пример #8
0
 function check($php_files, $css_files, $other_files)
 {
     $ret = true;
     $check = AvadaRedux_ThemeCheck::get_instance();
     $avadaredux = $check::get_avadaredux_details($php_files);
     if ($avadaredux) {
         $blacklist = array('.tx' => __('AvadaRedux localization utilities', 'themecheck'), 'bin' => __('AvadaRedux Resting Diles', 'themecheck'), 'codestyles' => __('AvadaRedux Code Styles', 'themecheck'), 'tests' => __('AvadaRedux Unit Testing', 'themecheck'), 'class.avadaredux-plugin.php' => __('AvadaRedux Plugin File', 'themecheck'), 'bootstrap_tests.php' => __('AvadaRedux Boostrap Tests', 'themecheck'), '.travis.yml' => __('CI Testing FIle', 'themecheck'), 'phpunit.xml' => __('PHP Unit Testing', 'themecheck'));
         $errors = array();
         foreach ($blacklist as $file => $reason) {
             checkcount();
             if (file_exists($avadaredux['parent_dir'] . $file)) {
                 $errors[$avadaredux['parent_dir'] . $file] = $reason;
             }
         }
         if (!empty($errors)) {
             $error = '<span class="tc-lead tc-required">REQUIRED</span> ' . __('It appears that you have embedded the full AvadaRedux package inside your theme. You need only embed the <strong>AvadaReduxCore</strong> folder. Embedding anything else will get your rejected from theme submission. Suspected AvadaRedux package file(s):', 'avadaredux-framework');
             $error .= '<ol>';
             foreach ($errors as $key => $e) {
                 $error .= '<li><strong>' . $e . '</strong>: ' . $key . '</li>';
             }
             $error .= '</ol>';
             $this->error[] = '<div class="avadaredux-error">' . $error . '</div>';
             $ret = false;
         }
     }
     return $ret;
 }
Пример #9
0
 function check($php_files, $css_files, $other_files)
 {
     $ret = true;
     checkcount();
     /**
      * Check whether every Customizer setting has a sanitization callback set.
      */
     foreach ($php_files as $file_path => $file_content) {
         // Get the arguments passed to the add_setting method
         if (preg_match_all('/\\$wp_customize->add_setting\\(([^;]+)/', $file_content, $matches)) {
             // The full match is in [0], the match group in [1]
             foreach ($matches[1] as $match) {
                 // Check if we have sanitize_callback or sanitize_js_callback
                 if (false === strpos($match, 'sanitize_callback') && false === strpos($match, 'sanitize_js_callback')) {
                     $this->error[] = '<span class="tc-lead tc-required">' . __('REQUIRED', 'theme-check') . '</span>: ' . __('Found a Customizer setting that did not have a sanitization callback function. Every call to the <strong>add_setting()</strong> method needs to have a sanitization callback function passed.', 'theme-check');
                     $ret = false;
                 } else {
                     // There's a callback, check that no empty parameter is passed.
                     if (preg_match('/[\'"](?:sanitize_callback|sanitize_js_callback)[\'"]\\s*=>\\s*[\'"]\\s*[\'"]/', $match)) {
                         $this->error[] = '<span class="tc-lead tc-required">' . __('REQUIRED', 'theme-check') . '</span>: ' . __('Found a Customizer setting that had an empty value passed as sanitization callback. You need to pass a function name as sanitization callback.', 'theme-check');
                         $ret = false;
                     }
                 }
             }
         }
     }
     return $ret;
 }
Пример #10
0
 function check($php_files, $css_files, $other_files)
 {
     checkcount();
     $ret = true;
     $filenames = array();
     foreach ($css_files as $cssfile => $content) {
         if (basename($cssfile) === 'style.css') {
             $data = get_theme_data_from_contents($content);
         }
     }
     if (!$data['Tags']) {
         $this->error[] = '<span class="tc-lead tc-recommended">' . __('RECOMMENDED', 'theme-check') . '</span>: ' . __('<strong>Tags:</strong> is either empty or missing in style.css header.', 'theme-check');
         return $ret;
     }
     $deprecated_tags = array("flexible-width", "fixed-width", "black", "blue", "brown", "gray", "green", "orange", "pink", "purple", "red", "silver", "tan", "white", "yellow", "dark", "light", "fixed-layout", "fluid-layout", "responsive-layout", "blavatar", "holiday", "photoblogging", "seasonal");
     $allowed_tags = array('grid-layout', "one-column", "two-columns", "three-columns", "four-columns", "left-sidebar", "right-sidebar", "flexible-header", 'footer-widgets', "accessibility-ready", "buddypress", "custom-background", "custom-colors", "custom-header", "custom-menu", "custom-logo", "editor-style", "featured-image-header", "featured-images", "front-page-post-form", "full-width-template", "microformats", "post-formats", "rtl-language-support", "sticky-post", "theme-options", "threaded-comments", "translation-ready", 'blog', 'e-commerce', 'education', 'entertainment', 'food-and-drink', 'holiday', 'news', 'photography', 'portfolio');
     foreach ($data['Tags'] as $tag) {
         if (strpos(strtolower($tag), "accessibility-ready") !== false) {
             $this->error[] = '<span class="tc-lead tc-info">' . __('INFO', 'theme-check') . '</span>: ' . __('Themes that use the tag accessibility-ready will need to undergo an accessibility review.', 'theme-check') . ' ' . __('See <a href="https://make.wordpress.org/themes/handbook/review/accessibility/">https://make.wordpress.org/themes/handbook/review/accessibility/</a>', 'theme-check');
         }
         if (!in_array(strtolower($tag), $allowed_tags)) {
             if (in_array(strtolower($tag), $deprecated_tags)) {
                 $this->error[] = '<span class="tc-lead tc-warning">' . __('WARNING', 'theme-check') . '</span>: ' . sprintf(__('The tag %s has been deprecated, please remove it from your style.css header.', 'theme-check'), '<strong>' . $tag . '</strong>');
             } else {
                 $this->error[] = '<span class="tc-lead tc-warning">' . __('WARNING', 'theme-check') . '</span>: ' . sprintf(__('Found wrong tag, remove %s from your style.css header.', 'theme-check'), '<strong>' . $tag . '</strong>');
                 $ret = false;
             }
         }
     }
     return $ret;
 }
Пример #11
0
 function check($php_files, $css_files, $other_files)
 {
     $ret = true;
     // combine all the php files into one string to make it easier to search
     $php = implode(' ', $php_files);
     checkcount();
     // no widgets registered or used...
     if (strpos($php, 'register_sidebar') === false && strpos($php, 'dynamic_sidebar') === false) {
         $this->error[] = "<span class='tc-lead tc-recommended'>" . __("RECOMMENDED", 'theme-check') . '</span>: ' . __("This theme contains no sidebars/widget areas. See <a href='https://codex.wordpress.org/Widgets_API'>Widgets API</a>", "theme-check");
         $ret = true;
     }
     if (strpos($php, 'register_sidebar') !== false && strpos($php, 'dynamic_sidebar') === false) {
         $this->error[] = "<span class='tc-lead tc-required'>" . __("REQUIRED", 'theme-check') . '</span>: ' . __("The theme appears to use <strong>register_sidebar()</strong> but no <strong>dynamic_sidebar()</strong> was found. See: <a href='https://codex.wordpress.org/Function_Reference/dynamic_sidebar'>dynamic_sidebar</a><pre> &lt;?php dynamic_sidebar( \$index ); ?&gt;</pre>", "theme-check");
         $ret = false;
     }
     if (strpos($php, 'register_sidebar') === false && strpos($php, 'dynamic_sidebar') !== false) {
         $this->error[] = "<span class='tc-lead tc-required'>" . __("REQUIRED", 'theme-check') . '</span>: ' . __("The theme appears to use <strong>dynamic_sidebars()</strong> but no <strong>register_sidebar()</strong> was found. See: <a href='https://codex.wordpress.org/Function_Reference/register_sidebar'>register_sidebar</a><pre> &lt;?php register_sidebar( \$args ); ?&gt;</pre>", "theme-check");
         $ret = false;
     }
     /**
      * There are widgets registered, is the widgets_init action present?
      */
     if (strpos($php, 'register_sidebar') !== false && preg_match('/add_action\\(\\s*("|\')widgets_init("|\')\\s*,/', $php) == false) {
         $this->error[] = "<span class='tc-lead tc-required'>" . __("REQUIRED", 'theme-check') . '</span>: ' . sprintf(__("Sidebars need to be registered in a custom function hooked to the <strong>widgets_init</strong> action. See: %s.", "theme-check"), '<a href="https://codex.wordpress.org/Function_Reference/register_sidebar">register_sidebar()</a>');
         $ret = false;
     }
     return $ret;
 }
Пример #12
0
 function check($php_files, $css_files, $other_files)
 {
     $ret = true;
     $check = Redux_ThemeCheck::get_instance();
     $redux = $check::get_redux_details($php_files);
     if ($redux) {
         if (!isset($_POST['redux_wporg'])) {
             checkcount();
             $this->error[] = '<div class="redux-error">' . sprintf(__('<span class="tc-lead tc-recommended">RECOMMENDED</span>: If you are submitting to WordPress.org Theme Repository, it is <strong>strongly</strong> suggested that you read <a href="%1" target="_blank">this document</a>, or your theme will be rejected because of Redux.', 'redux-framework'), 'https://docs.reduxframework.com/core/wordpress-org-submissions/') . '</div>';
             $ret = false;
         } else {
             // TODO Granular WP.org tests!!!
             // Check for Tracking
             checkcount();
             $tracking = $redux['dir'] . 'inc/tracking.php';
             if (file_exists($tracking)) {
                 $this->error[] = '<div class="redux-error">' . sprintf(__('<span class="tc-lead tc-required">REQUIRED</span>: You MUST delete <strong> %s </strong>, or your theme will be rejected by WP.org theme submission because of Redux.', 'redux-framework'), $tracking) . '</div>';
                 $ret = false;
             }
             // Embedded CDN package
             //use_cdn
             // Arguments
             checkcount();
             $args = '<ol>';
             $args .= "<li><code>'save_defaults' => false</code></li>";
             $args .= "<li><code>'use_cdn' => false</code></li>";
             $args .= "<li><code>'customizer_only' => true</code> Non-Customizer Based Panels are Prohibited within WP.org Themes</li>";
             $args .= "<li><code>'database' => 'theme_mods'</code> (" . __('Optional', 'redux-framework') . ")</li>";
             $args .= '</ol>';
             $this->error[] = '<div class="redux-error">' . __('<span class="tc-lead tc-recommended">RECOMMENDED</span>: The following arguments MUST be used for WP.org submissions, or you will be rejected because of your Redux configuration.', 'redux-framework') . $args . '</div>';
         }
     }
     return $ret;
 }
Пример #13
0
 function check($php_files, $css_files, $other_files)
 {
     $grep = '';
     $ret = true;
     $checks = array(array('get_postdata' => 'get_post()', '1.5.1'), array('start_wp' => 'the Loop', '1.5'), array('the_category_id' => 'get_the_category()', '0.71'), array('the_category_head' => 'get_the_category_by_ID()', '0.71'), array('previous_post' => 'previous_post_link()', '2.0'), array('next_post' => 'next_post_link()', '2.0'), array('user_can_create_post' => 'current_user_can()', '2.0'), array('user_can_create_draft' => 'current_user_can()', '2.0'), array('user_can_edit_post' => 'current_user_can()', '2.0'), array('user_can_delete_post' => 'current_user_can()', '2.0'), array('user_can_set_post_date' => 'current_user_can()', '2.0'), array('user_can_edit_post_comments' => 'current_user_can()', '2.0'), array('user_can_delete_post_comments' => 'current_user_can()', '2.0'), array('user_can_edit_user' => 'current_user_can()', '2.0'), array('get_linksbyname' => 'get_bookmarks()', '2.1'), array('wp_get_linksbyname' => 'wp_list_bookmarks()', '2.1'), array('get_linkobjectsbyname' => 'get_bookmarks()', '2.1'), array('get_linkobjects' => 'get_bookmarks()', '2.1'), array('get_linksbyname_withrating' => 'get_bookmarks()', '2.1'), array('get_links_withrating' => 'get_bookmarks()', '2.1'), array('get_autotoggle' => '', '2.1'), array('list_cats' => 'wp_list_categories', '2.1'), array('wp_list_cats' => 'wp_list_categories', '2.1'), array('dropdown_cats' => 'wp_dropdown_categories()', '2.1'), array('list_authors' => 'wp_list_authors()', '2.1'), array('wp_get_post_cats' => 'wp_get_post_categories()', '2.1'), array('wp_set_post_cats' => 'wp_set_post_categories()', '2.1'), array('get_archives' => 'wp_get_archives', '2.1'), array('get_author_link' => 'get_author_posts_url()', '2.1'), array('link_pages' => 'wp_link_pages()', '2.1'), array('get_settings' => 'get_option()', '2.1'), array('permalink_link' => 'the_permalink()', '1.2'), array('permalink_single_rss' => 'permalink_rss()', '2.3'), array('wp_get_links' => 'wp_list_bookmarks()', '2.1'), array('get_links' => 'get_bookmarks()', '2.1'), array('get_links_list' => 'wp_list_bookmarks()', '2.1'), array('links_popup_script' => '', '2.1'), array('get_linkrating' => 'sanitize_bookmark_field()', '2.1'), array('get_linkcatname' => 'get_category()', '2.1'), array('comments_rss_link' => 'post_comments_feed_link()', '2.5'), array('get_category_rss_link' => 'get_category_feed_link()' . '2.5'), array('get_author_rss_link' => 'get_author_feed_link()', '2.5'), array('comments_rss' => 'get_post_comments_feed_link()', '2.2'), array('create_user' => 'wp_create_user()', '2.0'), array('gzip_compression' => '', '2.5'), array('get_commentdata' => 'get_comment()', '2.7'), array('get_catname' => 'get_cat_name()', '2.8'), array('get_category_children' => 'get_term_children', '2.8'), array('get_the_author_description' => 'get_the_author_meta(\'description\')', '2.8'), array('the_author_description' => 'the_author_meta(\'description\')', '2.8'), array('get_the_author_login' => 'the_author_meta(\'login\')', '2.8'), array('get_the_author_firstname' => 'get_the_author_meta(\'first_name\')', '2.8'), array('the_author_firstname' => 'the_author_meta(\'first_name\')', '2.8'), array('get_the_author_lastname' => 'get_the_author_meta(\'last_name\')', '2.8'), array('the_author_lastname' => 'the_author_meta(\'last_name\')', '2.8'), array('get_the_author_nickname' => 'get_the_author_meta(\'nickname\')', '2.8'), array('the_author_nickname' => 'the_author_meta(\'nickname\')', '2.8'), array('get_the_author_email' => 'get_the_author_meta(\'email\')', '2.8'), array('the_author_email' => 'the_author_meta(\'email\')', '2.8'), array('get_the_author_icq' => 'get_the_author_meta(\'icq\')', '2.8'), array('the_author_icq' => 'the_author_meta(\'icq\')', '2.8'), array('get_the_author_yim' => 'get_the_author_meta(\'yim\')', '2.8'), array('the_author_yim' => 'the_author_meta(\'yim\')', '2.8'), array('get_the_author_msn' => 'get_the_author_meta(\'msn\')', '2.8'), array('the_author_msn' => 'the_author_meta(\'msn\')', '2.8'), array('get_the_author_aim' => 'get_the_author_meta(\'aim\')', '2.8'), array('the_author_aim' => 'the_author_meta(\'aim\')', '2.8'), array('get_author_name' => 'get_the_author_meta(\'display_name\')', '2.8'), array('get_the_author_url' => 'get_the_author_meta(\'url\')', '2.8'), array('the_author_url' => 'the_author_meta(\'url\')', '2.8'), array('get_the_author_ID' => 'get_the_author_meta(\'ID\')', '2.8'), array('the_author_ID' => 'the_author_meta(\'ID\')', '2.8'), array('the_content_rss' => 'the_content_feed()', '2.9'), array('make_url_footnote' => '', '2.9'), array('_c' => '_x()', '2.9'), array('translate_with_context' => '_x()', '3.0'), array('nc' => 'nx()', '3.0'), array('__ngettext' => '_n_noop()', '2.8'), array('__ngettext_noop' => '_n_noop()', '2.8'), array('get_alloptions' => 'wp_load_alloptions()', '3.0'), array('get_the_attachment_link' => 'wp_get_attachment_link()', '2.5'), array('get_attachment_icon_src' => 'wp_get_attachment_image_src()', '2.5'), array('get_attachment_icon' => 'wp_get_attachment_image()', '2.5'), array('get_attachment_innerhtml' => 'wp_get_attachment_image()', '2.5'), array('get_link' => 'get_bookmark()', '2.1'), array('sanitize_url' => 'esc_url()', '2.8'), array('clean_url' => 'esc_url()', '3.0'), array('js_escape' => 'esc_js()', '2.8'), array('wp_specialchars' => 'esc_html()', '2.8'), array('attribute_escape' => 'esc_attr()', '2.8'), array('register_sidebar_widget' => 'wp_register_sidebar_widget()', '2.8'), array('unregister_sidebar_widget' => 'wp_unregister_sidebar_widget()', '2.8'), array('register_widget_control' => 'wp_register_widget_control()', '2.8'), array('unregister_widget_control' => 'wp_unregister_widget_control()', '2.8'), array('delete_usermeta' => 'delete_user_meta()', '3.0'), array('get_usermeta' => 'get_user_meta()', '3.0'), array('update_usermeta' => 'update_user_meta()', '3.0'), array('automatic_feed_links' => 'add_theme_support( \'automatic-feed-links\' )', '3.0'), array('get_profile' => 'get_the_author_meta()', '3.0'), array('get_usernumposts' => 'count_user_posts()', '3.0'), array('funky_javascript_callback' => '', '3.0'), array('funky_javascript_fix' => '', '3.0'), array('is_taxonomy' => 'taxonomy_exists()', '3.0'), array('is_term' => 'term_exists()', '3.0'), array('is_plugin_page' => '$plugin_page and/or get_plugin_page_hookname() hooks', '3.1'), array('update_category_cache' => 'No alternatives', '3.1'), array('get_users_of_blog' => 'get_users()', '3.1'), array('wp_timezone_supported' => '', '3.2'), array('the_editor' => 'wp_editor', '3.3'), array('get_user_metavalues' => '', '3.3'), array('sanitize_user_object' => '', '3.3'), array('get_boundary_post_rel_link' => '', '3.3'), array('start_post_rel_link' => 'none available ', '3.3'), array('get_index_rel_link' => '', '3.3'), array('index_rel_link' => '', '3.3'), array('get_parent_post_rel_link' => '', '3.3'), array('parent_post_rel_link' => '', '3.3'), array('wp_admin_bar_dashboard_view_site_menu' => '', '3.3'), array('is_blog_user' => 'is_member_of_blog()', '3.3'), array('debug_fopen' => 'error_log()', '3.3'), array('debug_fwrite' => 'error_log()', '3.3'), array('debug_fclose' => 'error_log()', '3.3'), array('get_themes' => 'wp_get_themes()', '3.4'), array('get_theme' => 'wp_get_theme()', '3.4'), array('get_current_theme' => 'wp_get_theme()', '3.4'), array('clean_pre' => '', '3.4'), array('add_custom_image_header' => 'add_theme_support( \'custom-header\', $args )', '3.4'), array('remove_custom_image_header' => 'remove_theme_support( \'custom-header\' )', '3.4'), array('add_custom_background' => 'add_theme_support( \'custom-background\', $args )', '3.4'), array('remove_custom_background' => 'remove_theme_support( \'custom-background\' )', '3.4'), array('get_theme_data' => 'wp_get_theme()', '3.4'), array('update_page_cache' => 'update_post_cache()', '3.4'), array('clean_page_cache' => 'clean_post_cache()', '3.4'), array('wp_explain_nonce' => 'wp_nonce_ays', '3.4.1'), array('sticky_class' => 'post_class()', '3.5'), array('_get_post_ancestors' => '', '3.5'), array('wp_load_image' => 'wp_get_image_editor()', '3.5'), array('image_resize' => 'wp_get_image_editor()', '3.5'), array('wp_get_single_post' => 'get_post()', '3.5'), array('user_pass_ok' => 'wp_authenticate()', '3.5'), array('_save_post_hook' => '', '3.5'), array('gd_edit_image_support' => 'wp_image_editor_supports', '3.5'), array('get_user_id_from_string' => 'get_user_by()', '3.6'), array('wp_convert_bytes_to_hr' => 'size_format()', '3.6'), array('_search_terms_tidy' => '', '3.7'), array('get_blogaddress_by_domain' => '', '3.7'), array('tinymce_include' => 'wp_tiny_mce()', '2.1'), array('documentation_link' => '', '2.5'), array('wp_shrink_dimensions' => 'wp_constrain_dimensions()', '3.0'), array('dropdown_categories' => 'wp_category_checklist()', '2.6'), array('dropdown_link_categories' => 'wp_link_category_checklist()', '2.6'), array('wp_dropdown_cats' => 'wp_dropdown_categories()', '3.0'), array('add_option_update_handler' => 'register_setting()', '3.0'), array('remove_option_update_handler' => 'unregister_setting()', '3.0'), array('codepress_get_lang' => '', '3.0'), array('codepress_footer_js' => '', '3.0'), array('use_codepress' => '', '3.0'), array('get_author_user_ids' => '', '3.1'), array('get_editable_authors' => '', '3.1'), array('get_editable_user_ids' => '', '3.1'), array('get_nonauthor_user_ids' => '', '3.1'), array('WP_User_Search' => 'WP_User_Query', '3.1'), array('get_others_unpublished_posts' => '', '3.1'), array('get_others_drafts' => '', '3.1'), array('get_others_pending' => '', '3.1'), array('wp_dashboard_quick_press()' => '', '3.2'), array('wp_tiny_mce' => 'wp_editor', '3.2'), array('wp_preload_dialogs' => 'wp_editor()', '3.2'), array('wp_print_editor_js' => 'wp_editor()', '3.2'), array('wp_quicktags' => 'wp_editor()', '3.2'), array('favorite_actions' => 'WP_Admin_Bar', '3.2'), array('screen_layout' => '$current_screen->render_screen_layout()', '3.3'), array('screen_options' => '$current_screen->render_per_page_options()', '3.3'), array('screen_meta' => ' $current_screen->render_screen_meta()', '3.3'), array('media_upload_image' => 'wp_media_upload_handler()', '3.3'), array('media_upload_audio' => 'wp_media_upload_handler()', '3.3'), array('media_upload_video' => 'wp_media_upload_handler()', '3.3'), array('media_upload_file' => 'wp_media_upload_handler()', '3.3'), array('type_url_form_image' => 'wp_media_insert_url_form( \'image\' )', '3.3'), array('type_url_form_audio' => 'wp_media_insert_url_form( \'audio\' )', '3.3'), array('type_url_form_video' => 'wp_media_insert_url_form( \'video\' )', '3.3'), array('type_url_form_file' => 'wp_media_insert_url_form( \'file\' )', '3.3'), array('add_contextual_help' => 'get_current_screen()->add_help_tab()', '3.3'), array('get_allowed_themes' => 'wp_get_themes( array( \'allowed\' => true ) )', '3.4'), array('get_broken_themes' => 'wp_get_themes( array( \'errors\' => true )', '3.4'), array('current_theme_info' => 'wp_get_theme()', '3.4'), array('_insert_into_post_button' => '', '3.5'), array('_media_button' => '', '3.5'), array('get_post_to_edit' => 'get_post()', '3.5'), array('get_default_page_to_edit' => 'get_default_post_to_edit()', '3.5'), array('wp_create_thumbnail' => 'image_resize()', '3.5'), array('wp_nav_menu_locations_meta_box' => '', '3.6'), array('the_attachment_links' => '', '3.7'), array('wp_update_core' => 'new Core_Upgrader()', '3.7'), array('wp_update_plugin' => 'new Plugin_Upgrader()', '3.7'), array('wp_update_theme' => 'new Theme_Upgrader()', '3.7'), array('get_screen_icon' => '', '3.8'), array('screen_icon' => '', '3.8'), array('wp_dashboard_incoming_links' => '', '3.8'), array('wp_dashboard_incoming_links_control' => '', '3.8'), array('wp_dashboard_incoming_links_output' => '', '3.8'), array('wp_dashboard_plugins' => '', '3.8'), array('wp_dashboard_primary_control' => '', '3.8'), array('wp_dashboard_recent_comments_control' => '', '3.8'), array('wp_dashboard_secondary' => '', '3.8'), array('wp_dashboard_secondary_control' => '', '3.8'), array('wp_dashboard_secondary_output' => '', '3.8'));
     foreach ($php_files as $php_key => $phpfile) {
         foreach ($checks as $alt => $check) {
             checkcount();
             $key = key($check);
             $alt = $check[$key];
             if (preg_match('/[\\s?]' . $key . '\\(/', $phpfile, $matches)) {
                 $filename = tc_filename($php_key);
                 $error = ltrim(rtrim($matches[0], '('));
                 $version = $check[0];
                 $grep = tc_grep($error, $php_key);
                 // Point out the deprecated function.
                 $error_msg = sprintf(__('%1$s found in the file %2$s. Deprecated since version %3$s.', 'theme-check'), '<strong>' . $error . '()</strong>', '<strong>' . $filename . '</strong>', '<strong>' . $version . '</strong>');
                 // Add alternative function when available.
                 if ($alt) {
                     $error_msg .= ' ' . sprintf(__('Use %s instead.', 'theme-check'), '<strong>' . $alt . '</strong>');
                 }
                 // Add the precise code match that was found.
                 $error_msg .= $grep;
                 // Add the finalized error message.
                 $this->error[] = '<span class="tc-lead tc-required">' . __('REQUIRED', 'theme-check') . '</span>: ' . $error_msg;
                 $ret = false;
             }
         }
     }
     return $ret;
 }
Пример #14
0
 function check($php_files, $css_files, $other_files)
 {
     $ret = true;
     $checks = array('/(?<![_|a-z0-9|\\.])eval\\s?\\(/i' => __('eval() is not allowed.', 'themecheck'), '/[^a-z0-9](?<!_)(popen|proc_open|[^_]exec|shell_exec|system|passthru)\\(/' => __('PHP sytem calls should be disabled by server admins anyway!', 'themecheck'), '/\\s?ini_set\\(/' => __('Themes should not change server PHP settings', 'themecheck'), '/uudecode/ims' => __('uudecode() is not allowed', 'themecheck'), '/str_rot13/ims' => __('str_rot13() is not allowed', 'themecheck'), '/cx=[0-9]{21}:[a-z0-9]{10}/' => __('Google search code detected', 'themecheck'), '/pub-[0-9]{16}/i' => __('Googe advertising code detected', 'themecheck'));
     $grep = '';
     foreach ($php_files as $php_key => $phpfile) {
         foreach ($checks as $key => $check) {
             checkcount();
             if (preg_match($key, $phpfile, $matches)) {
                 $filename = tc_filename($php_key);
                 $error = ltrim(trim($matches[0], '('));
                 $grep = tc_grep($error, $php_key);
                 $this->error[] = sprintf(__('<span class="tc-lead tc-warning">WARNING</span>: Found <strong>%1$s</strong> in the file <strong>%2$s</strong>. %3$s. %4$s', 'themecheck'), $error, $filename, $check, $grep);
                 $ret = false;
             }
         }
     }
     $checks = array('/cx=[0-9]{21}:[a-z0-9]{10}/' => __('Google search code detected', 'themecheck'), '/pub-[0-9]{16}/' => __('Google advertising code detected', 'themecheck'));
     foreach ($other_files as $php_key => $phpfile) {
         foreach ($checks as $key => $check) {
             checkcount();
             if (preg_match($key, $phpfile, $matches)) {
                 $filename = tc_filename($php_key);
                 $error = ltrim(rtrim($matches[0], '('));
                 $grep = tc_grep($error, $php_key);
                 $this->error[] = sprintf(__('<span class="tc-lead tc-warning">WARNING</span>: Found <strong>%1$s</strong> in the file <strong>%2$s</strong>. %3$s.%4$s', 'themecheck'), $error, $filename, $check, $grep);
                 $ret = false;
             }
         }
     }
     return $ret;
 }
Пример #15
0
 function check($php_files, $css_files, $other_files)
 {
     checkcount();
     $ret = true;
     $filenames = array();
     foreach ($css_files as $cssfile => $content) {
         if (basename($cssfile) === 'style.css') {
             $data = get_theme_data_from_contents($content);
         }
     }
     if (!$data['Tags']) {
         $this->error[] = '<span class="tc-lead tc-recommended">' . __('RECOMMENDED', 'theme-check') . '</span>: ' . __('<strong>Tags:</strong> is either empty or missing in style.css header.', 'theme-check');
         return $ret;
     }
     $allowed_tags = array("black", "blue", "brown", "gray", "green", "orange", "pink", "purple", "red", "silver", "tan", "white", "yellow", "dark", "light", "one-column", "two-columns", "three-columns", "four-columns", "left-sidebar", "right-sidebar", "fixed-layout", "fluid-layout", "responsive-layout", "flexible-header", "accessibility-ready", "blavatar", "buddypress", "custom-background", "custom-colors", "custom-header", "custom-menu", "editor-style", "featured-image-header", "featured-images", "front-page-post-form", "full-width-template", "microformats", "post-formats", "rtl-language-support", "sticky-post", "theme-options", "threaded-comments", "translation-ready", "holiday", "photoblogging", "seasonal");
     foreach ($data['Tags'] as $tag) {
         if (!in_array(strtolower($tag), $allowed_tags)) {
             if (in_array(strtolower($tag), array("flexible-width", "fixed-width"))) {
                 $this->error[] = '<span class="tc-lead tc-warning">' . __('WARNING', 'theme-check') . '</span>: ' . __('The flexible-width and fixed-width tags changed to fluid-layout and fixed-layout tags in WordPress 3.8. Additionally, the responsive-layout tag was added. Please change to using one of the new tags.', 'theme-check');
             } else {
                 $this->error[] = '<span class="tc-lead tc-warning">' . __('WARNING', 'theme-check') . '</span>: ' . sprintf(__('Found wrong tag, remove %s from your style.css header.', 'theme-check'), '<strong>' . $tag . '</strong>');
                 $ret = false;
             }
         }
     }
     return $ret;
 }
Пример #16
0
 function check($php_files, $css_files, $other_files)
 {
     $php = implode(' ', $php_files);
     $grep = '';
     $ret = true;
     $checks = array('DOCTYPE' => __('See: <a href="https://codex.wordpress.org/HTML_to_XHTML">https://codex.wordpress.org/HTML_to_XHTML</a><pre>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"<br />"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"?&gt;</pre>', 'theme-check'), 'wp_footer\\(' => __('See: <a href="https://codex.wordpress.org/Function_Reference/wp_footer">wp_footer</a><pre> &lt;?php wp_footer(); ?&gt;</pre>', 'theme-check'), 'wp_head\\(' => __('See: <a href="https://codex.wordpress.org/Function_Reference/wp_head">wp_head</a><pre> &lt;?php wp_head(); ?&gt;</pre>', 'theme-check'), 'language_attributes' => __('See: <a href="https://codex.wordpress.org/Function_Reference/language_attributes">language_attributes</a><pre>&lt;html &lt;?php language_attributes(); ?&gt;</pre>', 'theme-check'), 'charset' => __('There must be a charset defined in the Content-Type or the meta charset tag in the head.', 'theme-check'), 'add_theme_support\\(\\s?("|\')automatic-feed-links("|\')\\s?\\)' => __('See: <a href="https://codex.wordpress.org/Function_Reference/add_theme_support">add_theme_support</a><pre> &lt;?php add_theme_support( $feature ); ?&gt;</pre>', 'theme-check'), 'comments_template\\(' => __('See: <a href="https://codex.wordpress.org/Template_Tags/comments_template">comments_template</a><pre> &lt;?php comments_template( $file, $separate_comments ); ?&gt;</pre>', 'theme-check'), 'wp_list_comments\\(' => __('See: <a href="https://codex.wordpress.org/Template_Tags/wp_list_comments">wp_list_comments</a><pre> &lt;?php wp_list_comments( $args ); ?&gt;</pre>', 'theme-check'), 'comment_form\\(' => __('See: <a href="https://codex.wordpress.org/Template_Tags/comment_form">comment_form</a><pre> &lt;?php comment_form(); ?&gt;</pre>', 'theme-check'), 'body_class' => __('See: <a href="https://codex.wordpress.org/Template_Tags/body_class">body_class</a><pre> &lt;?php body_class( $class ); ?&gt;</pre>', 'theme-check'), 'wp_link_pages\\(' => __('See: <a href="https://codex.wordpress.org/Function_Reference/wp_link_pages">wp_link_pages</a><pre> &lt;?php wp_link_pages( $args ); ?&gt;</pre>', 'theme-check'), 'post_class\\(' => __('See: <a href="https://codex.wordpress.org/Template_Tags/post_class">post_class</a><pre> &lt;div id="post-&lt;?php the_ID(); ?&gt;" &lt;?php post_class(); ?&gt;&gt;</pre>', 'theme-check'));
     foreach ($checks as $key => $check) {
         checkcount();
         if (!preg_match('/' . $key . '/i', $php)) {
             if ($key === 'add_theme_support\\(\\s?("|\')automatic-feed-links("|\')\\s?\\)') {
                 $key = __('add_theme_support( \'automatic-feed-links\' )', 'theme-check');
             }
             if ($key === 'wp_enqueue_script\\(\\s?("|\')comment-reply("|\')') {
                 $key = __('wp_enqueue_script( \'comment-reply\' )', 'theme-check');
             }
             if ($key === 'body_class') {
                 $key = __('body_class call in body tag', 'theme-check');
             }
             if ($key === 'register_sidebar[s]?\\(') {
                 $key = __('register_sidebar() or register_sidebars()', 'theme-check');
             }
             $key = ltrim(trim(trim($key, '('), '\\'));
             $this->error[] = sprintf('<span class="tc-lead tc-required">' . __('REQUIRED', 'theme-check') . '</span>: ' . __('Could not find <strong>%1$s</strong>. %2$s', 'theme-check'), $key, $check);
             $ret = false;
         }
     }
     return $ret;
 }
Пример #17
0
 function check($php_files, $css_files, $other_files)
 {
     $ret = true;
     global $data;
     foreach ($php_files as $php_key => $phpfile) {
         checkcount();
         $grep = '';
         // regex borrowed from TAC
         $url_re = '([[:alnum:]\\-\\.])+(\\.)([[:alnum:]]){2,4}([[:blank:][:alnum:]\\/\\+\\=\\%\\&\\_\\\\.\\~\\?\\-]*)';
         $title_re = '[[:blank:][:alnum:][:punct:]]*';
         // 0 or more: any num, letter(upper/lower) or any punc symbol
         $space_re = '(\\s*)';
         if (preg_match_all("/(<a)(\\s+)(href" . $space_re . "=" . $space_re . "\"" . $space_re . "((http|https|ftp):\\/\\/)?)" . $url_re . "(\"" . $space_re . $title_re . $space_re . ">)" . $title_re . "(<\\/a>)/is", $phpfile, $out, PREG_SET_ORDER)) {
             $filename = tc_filename($php_key);
             foreach ($out as $key) {
                 if (preg_match('/\\<a\\s?href\\s?=\\s?["|\'](.*?)[\'|"](.*?)\\>(.*?)\\<\\/a\\>/is', $key[0], $stripped)) {
                     if (!empty($data['AuthorURI']) && !empty($data['URI']) && $stripped[1] && !strpos($stripped[1], $data['URI']) && !strpos($stripped[1], $data['AuthorURI']) && !strpos($stripped[1], 'wordpress.')) {
                         $grep .= tc_grep($stripped[1], $php_key);
                     }
                 }
                 if ($grep) {
                     $this->error[] = sprintf('<span class="tc-lead tc-info">' . __('INFO', 'theme-check') . '</span>: ' . __('Possible hard-coded links were found in the file <strong>%1$s</strong>.%2$s', 'theme-check'), $filename, $grep);
                 }
             }
         }
     }
     return $ret;
 }
Пример #18
0
 function check($php_files, $css_files, $other_files)
 {
     global $data, $themename;
     $ret = true;
     $error = '';
     checkcount();
     if ($data['Name'] === 'Twenty Ten' || $data['Name'] === 'Twenty Eleven') {
         return $ret;
     }
     $checks = array('/[\\s|\\(|;]_[e|_]\\s?\\(\\s?[\'|"][^\'|"]*[\'|"]\\s?\\)/' => __('You have not included a text domain!', 'theme-check'));
     foreach ($php_files as $php_key => $phpfile) {
         $error = '';
         foreach ($checks as $key => $check) {
             checkcount();
             if (preg_match_all($key, $phpfile, $matches) || preg_match_all('/[\\s|\\(]_x\\s?\\(\\s?[\'|"][^\'|"]*[\'|"]\\s?,\\s?[\'|"][^\'|"]*[\'|"]\\s?\\)/', $phpfile, $matches)) {
                 $filename = tc_filename($php_key);
                 foreach ($matches[0] as $match) {
                     $grep = tc_grep(ltrim($match), $php_key);
                     preg_match('/[^\\s]*\\s[0-9]+/', $grep, $line);
                     $error .= !strpos($error, $line[0]) ? $grep : '';
                 }
                 $this->error[] = sprintf("<span class='tc-lead tc-recommended'>" . __('RECOMMENDED', 'theme-check') . '</span>: ' . __('Text domain problems in <strong>%1$s</strong>. %2$s %3$s ', 'theme-check'), $filename, $check, $error);
             }
         }
     }
     $checks = array('/[\\s|\\(]_[e|_]\\s?\\([^,|;]*\\s?,\\s?[\'|"]([^\'|"]*)[\'|"]\\s?\\)/' => sprintf(__('Text domain should match theme slug: <strong>%1$s</strong>', 'theme-check'), $themename), '/[\\s|\\(]_x\\s?\\([^,]*\\s?,\\s[^\'|"]*[\'|"][^\'|"]*[\'|"],\\s?[\'|"]([^\'|"]*)[\'|"]\\s?\\)/' => sprintf(__('Text domain should match theme slug: <strong>%1$s</strong>', 'theme-check'), $themename));
     foreach ($php_files as $php_key => $phpfile) {
         foreach ($checks as $key => $check) {
             checkcount();
             if (preg_match_all($key, $phpfile, $matches)) {
                 foreach ($matches[0] as $count => $domaincheck) {
                     if (preg_match('/[\\s|\\(]_[e|_]\\s?\\(\\s?[\'|"][^\'|"]*[\'|"]\\s?\\)/', $domaincheck)) {
                         unset($matches[1][$count]);
                     }
                     //filter out false positives
                 }
                 $filename = tc_filename($php_key);
                 $count = 0;
                 while (isset($matches[1][$count])) {
                     if ($matches[1][$count] !== $themename) {
                         $error = tc_grep($matches[0][$count], $php_key);
                         if ($matches[1][$count] === 'twentyten' || $matches[1][$count] === 'twentyeleven') {
                             $this->error[] = sprintf('<span class=\'tc-lead tc-recommended\'>' . __('RECOMMENDED', 'theme-check') . '</span>: ' . __('Text domain problems in <strong>%1$s</strong>. The %2$s text domain is being used!%3$s', 'theme-check'), $filename, $matches[1][$count], $error);
                         } else {
                             if (defined('TC_TEST') && strpos(strtolower($themename), $matches[1][$count]) === false) {
                                 $error = tc_grep($matches[0][$count], $php_key);
                                 $this->error[] = sprintf('<span class=\'tc-lead tc-recommended\'>' . __('RECOMMENDED', 'theme-check') . '</span>: ' . __('Text domain problems in <strong>%1$s</strong>. %2$s You are using: <strong>%3$s</strong>%4$s', 'theme-check'), $filename, $check, $matches[1][$count], $error);
                             }
                         }
                     }
                     $count++;
                 }
                 //end while
             }
         }
     }
     return $ret;
 }
Пример #19
0
 function check($php_files, $css_files, $other_files)
 {
     checkcount();
     $ret = true;
     $php = implode(' ', $php_files);
     if (strpos($php, 'add_editor_style') === false) {
         $this->error[] = '<span class="tc-lead tc-recommended">' . __('RECOMMENDED', 'theme-check') . '</span>: ' . __('No reference to <strong>add_editor_style()</strong> was found in the theme. It is recommended that the theme implement editor styling, so as to make the editor content match the resulting post output in the theme, for a better user experience.', 'theme-check');
     }
     return $ret;
 }
Пример #20
0
 function check($php_files, $css_files, $other_files)
 {
     $ret = true;
     $php = implode(' ', $php_files);
     checkcount();
     if (strpos($php, 'nav_menu') === false) {
         $this->error[] = '<span class="tc-lead tc-recommended">' . __('RECOMMENDED', 'theme-check') . '</span>: ' . __("No reference to nav_menu's was found in the theme. Note that if your theme has a menu bar, it is required to use the WordPress nav_menu functionality for it.", 'theme-check');
     }
     return $ret;
 }
Пример #21
0
 function check($php_files, $css_files, $other_files)
 {
     $ret = true;
     $error = '';
     checkcount();
     // make sure the tokenizer is available
     if (!function_exists('token_get_all')) {
         return true;
     }
     foreach ($php_files as $php_key => $phpfile) {
         $error = '';
         $stmts = array();
         foreach (array('_e(', '__(', '_e (', '__ (') as $finder) {
             $search = $phpfile;
             while (($pos = strpos($search, $finder)) !== false) {
                 $search = substr($search, $pos);
                 $open = 1;
                 $i = strpos($search, '(') + 1;
                 while ($open > 0) {
                     switch ($search[$i]) {
                         case '(':
                             $open++;
                             break;
                         case ')':
                             $open--;
                             break;
                     }
                     $i++;
                 }
                 $stmts[] = substr($search, 0, $i);
                 $search = substr($search, $i);
             }
         }
         foreach ($stmts as $match) {
             $tokens = @token_get_all('<?php ' . $match . ';');
             if (!empty($tokens)) {
                 foreach ($tokens as $token) {
                     if (is_array($token) && in_array($token[0], array(T_VARIABLE))) {
                         $filename = tc_filename($php_key);
                         $grep = tc_grep(ltrim($match), $php_key);
                         preg_match('/[^\\s]*\\s[0-9]+/', $grep, $line);
                         $error = '';
                         if (isset($line[0])) {
                             $error = !strpos($error, $line[0]) ? $grep : '';
                         }
                         $this->error[] = sprintf('<span class="tc-lead tc-recommended">' . __('RECOMMENDED', 'theme-check') . '</span>: ' . __('Possible variable %1$s found in translation function in %2$s. Translation function calls must NOT contain PHP variables. %3$s', 'theme-check'), '<strong>' . $token[1] . '</strong>', '<strong>' . $filename . '</strong>', $error);
                         break;
                         // stop looking at the tokens on this line once a variable is found
                     }
                 }
             }
         }
     }
     return $ret;
 }
Пример #22
0
 function check($php_files, $css_files, $other_files)
 {
     $ret = true;
     // combine all the php files into one string to make it easier to search
     $php = implode(' ', $php_files);
     checkcount();
     if (strpos($php, 'nav_menu') === false) {
         $this->error[] = __("<span class='tc-lead tc-recommended'>RECOMMENDED</span>: No reference to nav_menu's was found in the theme. Note that if your theme has a menu bar, it is required to use the WordPress nav_menu functionality for it.", "themecheck");
     }
     return $ret;
 }
Пример #23
0
 function check($php_files, $css_files, $other_files)
 {
     $php = implode(' ', $php_files);
     checkcount();
     $ret = true;
     if (strpos($php, 'get_avatar') === false && strpos($php, 'wp_list_comments') === false) {
         $this->error[] = '<span class="tc-lead tc-required">' . __('REQUIRED', 'theme-check') . '</span>: ' . __("This theme doesn't seem to support the standard avatar functions. Use <strong>get_avatar</strong> or <strong>wp_list_comments</strong> to add this support.", 'theme-check');
         $ret = false;
     }
     return $ret;
 }
Пример #24
0
 function check($php_files, $css_files, $other_files)
 {
     $ret = true;
     $php = implode(' ', $php_files);
     checkcount();
     if (strpos($php, 'the_tags') === false && strpos($php, 'get_the_tag_list') === false && strpos($php, 'get_the_term_list') === false) {
         $this->error[] = "<span class='tc-lead tc-required'>" . __('REQUIRED', 'theme-check') . '</span>: ' . __("This theme doesn't seem to display tags. Modify it to display tags in appropriate locations.", "theme-check");
         $ret = false;
     }
     return $ret;
 }
Пример #25
0
 function check($php_files, $css_files, $other_files)
 {
     $ret = true;
     $php = implode(' ', $php_files);
     checkcount();
     if (strpos($php, '$content_width') === false && strpos($php, '$GLOBALS' . "['content_width']") === false && !preg_match('/add_filter\\(\\s?("|\')embed_defaults/', $php) && !preg_match('/add_filter\\(\\s?("|\')content_width/', $php)) {
         $this->error[] = '<span class="tc-lead tc-required">' . __('REQUIRED', 'theme-check') . '</span>: ' . __('No content width has been defined. Example: <pre>if ( ! isset( $content_width ) ) $content_width = 900;</pre>', 'theme-check');
         $ret = false;
     }
     return $ret;
 }
Пример #26
0
 function check($php_files, $css_files, $other_files)
 {
     $ret = true;
     $php = implode(' ', $php_files);
     checkcount();
     if (strpos($php, 'paginate_comments_links') === false && strpos($php, 'the_comments_navigation') === false && (strpos($php, 'next_comments_link') === false && strpos($php, 'previous_comments_link') === false)) {
         $this->error[] = '<span class="tc-lead tc-required">' . __('REQUIRED', 'theme-check') . '</span>: ' . __('The theme doesn\'t have comment pagination code in it. Use <strong>paginate_comments_links()</strong> or <strong>the_comments_navigation</strong> or <strong>next_comments_link()</strong> and <strong>previous_comments_link()</strong> to add comment pagination.', 'theme-check');
         $ret = false;
     }
     return $ret;
 }
Пример #27
0
 function check($php_files, $css_files, $other_files)
 {
     $ret = true;
     $php = implode(' ', $php_files);
     checkcount();
     if (strpos($php, 'art_normalize_widget_style_tokens') !== false || strpos($php, 'art_include_lib') !== false || strpos($php, '_remove_last_slash($url) {') !== false || strpos($php, 'adi_normalize_widget_style_tokens') !== false || strpos($php, 'm_normalize_widget_style_tokens') !== false || strpos($php, "bw = '<!--- BEGIN Widget --->';") !== false || strpos($php, "ew = '<!-- end_widget -->';") !== false || strpos($php, "end_widget' => '<!-- end_widget -->'") !== false) {
         $this->error[] = "<span class='tc-lead tc-warning'>" . __('WARNING', 'theme-check') . "</span>: " . __('This theme appears to have been auto-generated. Generated themes are not allowed in the themes directory.', 'theme-check');
         $ret = false;
     }
     return $ret;
 }
Пример #28
0
 function check($php_files, $css_files, $other_files)
 {
     $ret = true;
     checkcount();
     foreach ($php_files as $file_path => $file_content) {
         $filename = tc_filename($file_path);
         if (preg_match('/(<link rel=[\'"]icon[\'"])|(<link rel=[\'"]apple-touch-icon-precomposed[\'"])|(<meta name=[\'"]msapplication-TileImage[\'"])/', $file_content, $matches)) {
             $this->error[] = sprintf('<span class="tc-lead tc-info">' . __('INFO', 'theme-check') . '</span>: ' . __('Possible Favicon found in %1$s. Favicons are handled by the Site Icon setting in the customizer since version 4.3.', 'theme-check'), '<strong>' . $filename . '</strong>');
         }
     }
     return $ret;
 }
Пример #29
0
 function check($php_files, $css_files, $other_files)
 {
     $ret = true;
     // combine all the php files into one string to make it easier to search
     $php = implode(' ', $php_files);
     checkcount();
     if (strpos($php, 'paginate_comments_links') === false && (strpos($php, 'next_comments_link') === false && strpos($php, 'previous_comments_link') === false)) {
         $this->error[] = __('<span class="tc-lead tc-required">REQUIRED</span>: The theme doesn\'t have comment pagination code in it. Use <strong>paginate_comments_links()</strong> or <strong>next_comments_link()</strong> and <strong>previous_comments_link()</strong> to add comment pagination.', 'themecheck');
         $ret = false;
     }
     return $ret;
 }
Пример #30
0
 function check($php_files, $css_files, $other_files)
 {
     $ret = true;
     // combine all the php files into one string to make it easier to search
     $php = implode(' ', $php_files);
     checkcount();
     if (strpos($php, 'posts_nav_link') === false && strpos($php, 'paginate_links') === false && strpos($php, 'the_posts_pagination') === false && (strpos($php, 'previous_posts_link') === false && strpos($php, 'next_posts_link') === false)) {
         $this->error[] = '<span class="tc-lead tc-required">' . __('REQUIRED', 'theme-check') . '</span>: ' . __("The theme doesn't have post pagination code in it. Use <strong>posts_nav_link()</strong> or <strong>paginate_links()</strong> or <strong>the_posts_pagination</strong> or <strong>next_posts_link()</strong> and <strong>previous_posts_link()</strong> to add post pagination.", 'theme-check');
         $ret = false;
     }
     return $ret;
 }