public static function FontStats() { if (isset($_POST['act']) && $_POST['act'] == 'update') { print "<div id=\"accwait\" style=\"font-size: 36px; padding-top: 15px;\"><center><strong>" . __("Wait, it may take a while...", self::PLUGIN_SLUG) . "</strong><br/><br/>"; print "<img src=\"" . PLUGIN_URL . "assets/loader.gif\"/></div>"; ob_flush(); GFontsDB::RecalculateStats(); GFontsUI::Success(__('Stats recalculated successfully.', self::PLUGIN_SLUG)); print "<script type=\"text/javascript\">jQuery('#accwait').hide();</script>"; } if (isset($_GET['act']) && $_GET['act'] == 'replace') { $p = $_POST; if (isset($p['srcfont']) && isset($p['dstfont'])) { print "<div id=\"accwait\" style=\"font-size: 36px; padding-top: 15px;\"><center><strong>" . __("Wait, it may take a while...", self::PLUGIN_SLUG) . "</strong><br/><br/>"; print "<img src=\"" . PLUGIN_URL . "assets/loader.gif\"/></div>"; ob_flush(); GFontsDB::ReplaceFont($p['srcfont'], $p['dstfont']); GFontsUI::Success(__('Fonts replaced successfully.', self::PLUGIN_SLUG)); print "<script type=\"text/javascript\">jQuery('#accwait').hide();</script>"; } } $count = count(GFontsDB::GetInstalledFonts()); $allFonts = self::AvailableFontCount(); $postsWithoutFonts = self::CountPostsWithoutFonts(); print "<div class='wrap'>"; print "<h2>" . __('Google Fonts - WordPress Font Statistics & Tools', self::PLUGIN_SLUG) . "</h2>"; print "<h3 class=\"title\">" . __('General information', self::PLUGIN_SLUG) . "</h3>"; print "<table border=\"0\">"; print "<tr>"; print "<td style=\"width: 200px;\">" . __('Google Fonts available', self::PLUGIN_SLUG) . "</td>"; print "<th style=\"width: 100px;\" align=\"left\">" . $allFonts . "</th>"; print "</tr>"; print "<tr>"; print "<td style=\"width: 200px;\">" . __('Google Fonts installed', self::PLUGIN_SLUG) . "</td>"; print "<th style=\"width: 100px;\" align=\"left\">" . $count . "</th>"; print "</tr>"; print "<tr>"; print "<td style=\"width: 200px;\">" . __('Posts without any font', self::PLUGIN_SLUG) . "</td>"; print "<th style=\"width: 100px;\" align=\"left\">" . $postsWithoutFonts . " (<a href=\"edit.php?gfontfilter=true&nofont=1\">" . __('view', self::PLUGIN_SLUG) . "</a>)</th>"; print "</tr>"; print "</table>"; print "<div style=\"height: 20px;\"></div>"; print "<form method=\"post\" action=\"admin.php?page=" . self::PLUGIN_SLUG . "&actio=" . self::PLUGIN_FONT_STATS . "\"><input type=\"hidden\" name=\"act\" value=\"update\"><button class=\"button button-primary\">" . __('Find and fix missing fonts', self::PLUGIN_SLUG) . "</button></form>"; if (isset($_GET['s']) && $_GET['s'] != '') { $nameFilter = strip_tags(trim($_GET['s'])); } else { $nameFilter = ''; } $orderby = ''; $direction = ''; if (isset($_GET['orderby'])) { switch ($_GET['orderby']) { case 'usedin': $orderby = 'used_in_posts'; break; case 'fontname': $orderby = 'name'; break; } switch ($_GET['order']) { case 'asc': $direction = 'asc'; break; case 'desc': $direction = 'desc'; break; } } $allFonts = GFontsDB::GetFontsWithPosts($nameFilter, $orderby, $direction); print "<form id=\"fonts-filter\" action=\"\" method=\"get\">"; print "<p class=\"search-box\">"; printf("<label class=\"screen-reader-text\" for=\"font-search-input\">%s :</label>", __("Search fonts", self::PLUGIN_SLUG)); printf("<input type=\"search\" id=\"font-search-input\" name=\"s\" value=\"%s\" />", $nameFilter); printf("<input type=\"submit\" name=\"\" id=\"search-submit\" class=\"button\" value=\"%s\" />", __("Search fonts", self::PLUGIN_SLUG)); print "</p>"; printf("<input type=\"hidden\" name=\"page\" value=\"%s\" />", self::PLUGIN_SLUG); printf("<input type=\"hidden\" name=\"actio\" value=\"%s\" />", self::PLUGIN_FONT_STATS); print "</form>"; print "<div class=\"tablenav top\">"; $paginationcode = ''; printf("<div class='tablenav-pages'><span class=\"displaying-num\">%s</span>%s</div>", sprintf(_n('%d font', '%d fonts', count($allFonts)), count($allFonts)), $paginationcode); print "</div>"; self::IncludeCssForFonts(true); print '<table class="wp-list-table widefat fixed" cellspacing="0">'; print '<thead>'; print '<tr>'; print '<th width=\'50%\' scope=\'col\' id=\'fontname\' class=\'manage-column column-fontname sortable ' . self::GetCurrentOrder() . ' \' style=""><a href="' . admin_url('admin.php?page=' . self::PLUGIN_SLUG . '&actio=' . self::PLUGIN_FONT_STATS . '&orderby=fontname&order=' . self::GetOrderBy()) . '"><span>' . __('Font', self::PLUGIN_SLUG) . '</span><span class="sorting-indicator"></span></a></th>'; print '<th width=\'50%\' scope=\'col\' id=\'usedin\' class=\'manage-column column-fontname sortable ' . self::GetCurrentOrder() . ' \' style=""><a href="' . admin_url('admin.php?page=' . self::PLUGIN_SLUG . '&actio=' . self::PLUGIN_FONT_STATS . '&orderby=usedin&order=' . self::GetOrderBy()) . '"><span>' . __('Used in posts', self::PLUGIN_SLUG) . '</span><span class="sorting-indicator"></span></a></th>'; print '</tr>'; print '</thead>'; print '<tfoot>'; print '<tr>'; print '<th scope=\'col\' id=\'fontname\' class=\'manage-column column-fontname sortable ' . self::GetCurrentOrder() . ' \' style=""><a href="' . admin_url('admin.php?page=' . self::PLUGIN_SLUG . '&actio=' . self::PLUGIN_FONT_STATS . '&orderby=fontname&order=' . self::GetOrderBy()) . '"><span>' . __('Font', self::PLUGIN_SLUG) . '</span><span class="sorting-indicator"></span></a></th>'; print '<th scope=\'col\' id=\'usedin\' class=\'manage-column column-fontname sortable ' . self::GetCurrentOrder() . ' \' style=""><a href="' . admin_url('admin.php?page=' . self::PLUGIN_SLUG . '&actio=' . self::PLUGIN_FONT_STATS . '&orderby=usedin&order=' . self::GetOrderBy()) . '"><span>' . __('Used in posts', self::PLUGIN_SLUG) . '</span><span class="sorting-indicator"></span></a></th>'; print '</tr>'; print '</tfoot>'; print '<tbody id="the-list">'; foreach ($allFonts as $fnt) { print '<tr id="fnt-' . $fnt->id . '" class="alternate iedit" valign="top" style="font-family: ' . $fnt->name . ';">'; print '<td style="font-size: 17px;">'; print '<strong>' . $fnt->name . '</strong>'; print '<div class="locked-info"><span class="locked-avatar"></span> <span class="locked-text"></span></div>'; print '<div>'; // class="row-actions">'; print "<form action=\"admin.php?page=" . self::PLUGIN_SLUG . "&actio=" . self::PLUGIN_FONT_STATS . "&act=replace\" method=\"post\" onsubmit=\"return confirm('Are you sure you want replace " . $fnt->name . " with selected font?');\">"; print "<span style=\"font-size: 12px; font-family: Verdana;\">Replace this font with </span>"; print "<select name=\"dstfont\" style=\"width: 200px; font-size: 12px; font-family: Verdana;\">"; $avFonts = GFontsDB::GetFontsToReplace($fnt->name); foreach ($avFonts as $font) { printf("<option value=\"%s\" >%s</option>", $font, $font); } print "</select>"; print "<input type=\"hidden\" name=\"srcfont\" value=\"" . $fnt->id . "\" />"; print "<input type=\"submit\" value=\"Change!\" class=\"button button-primary\" style=\"font-size: 12px; font-family: Verdana;\"/>"; print "</form>"; print '</div>'; print "<br/>"; print '</td>'; print '<td style="font-size: 17px;">'; print '<strong>' . sprintf(_n('%d post', '%d posts', $fnt->used_in_posts, self::PLUGIN_SLUG), $fnt->used_in_posts) . '</strong>'; if ($fnt->in_trash > 0) { print ' + <strong>' . sprintf(_n('%d post in trash', '%d posts in trash', $fnt->in_trash, self::PLUGIN_SLUG), $fnt->in_trash) . '</strong>'; } if ($fnt->total_used > 0) { print '<div class="locked-info"><span class="locked-avatar"></span> <span class="locked-text"></span></div>'; print '<div class="row-actions">'; print '<span class=\'view\'><a title=\'' . __('View', self::PLUGIN_SLUG) . '\' href=\'' . admin_url('edit.php?gfontfilter=1&gfid=' . $fnt->id) . '\' target="_blank">' . __('View', self::PLUGIN_SLUG) . '</a></span>'; if ($fnt->in_trash > 0) { print ' | <span class=\'view\'><a title=\'' . __('View in trash', self::PLUGIN_SLUG) . '\' href=\'' . admin_url('edit.php?post_status=trash&gfontfilter=1&gfid=' . $fnt->id) . '\' target="_blank">' . __('View in trash', self::PLUGIN_SLUG) . '</a></span>'; } print '</div>'; } print '</td>'; print '</tr>'; } print '</tbody>'; print '</table>'; }