public static function FontList() { print "<div class='wrap'>"; print "<h2>" . __('Google Fonts - List of installed fonts', self::PLUGIN_SLUG) . "</h2>"; if (isset($_GET['act']) && $_GET['act'] == 'uninstall') { $fid = isset($_GET['id']) ? intval($_GET['id']) : false; if (is_int($fid)) { GFontsDB::UninstallFontById($fid); GFontsUI::Success(__('Font uninstalled succesfully.', self::PLUGIN_SLUG)); } } if (isset($_GET['act']) && $_GET['act'] == 'bulk') { $t = $_POST; switch ($t['action']) { case 'uninstall': $fontArray = $t['font']; GFontsDB::UninstallFontByIdCollection($fontArray); GFontsUI::Success(__('Fonts uninstalled succesfully.', self::PLUGIN_SLUG)); break; } } 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; } } if (!isset($_GET['f'])) { $installedFonts = GFontsDB::GetInstalledFonts(0, $nameFilter, $orderby, $direction); } else { switch ($_GET['f']) { case 'used': $installedFonts = GFontsDB::GetInstalledFonts(1, $nameFilter, $orderby, $direction); break; case 'unused': $installedFonts = GFontsDB::GetInstalledFonts(2, $nameFilter, $orderby, $direction); break; } } $stats = GFontsDB::GetInstalledFontsStats(); print "<ul class='subsubsub'>"; printf("<li class='all'><a href='admin.php?%s' " . (!isset($_GET['f']) ? "class=\"current\"" : "") . ">%s <span class=\"count\">(%d)</span></a> |</li>", 'page=' . self::PLUGIN_SLUG . '&actio=' . self::PLUGIN_FONT_LIST, __('All', self::PLUGIN_SLUG), isset($stats[2]) ? $stats[2]->qty : 0); printf("<li class='used'><a href='admin.php?%s&f=used' " . (isset($_GET['f']) && $_GET['f'] == 'used' ? "class=\"current\"" : "") . ">%s <span class=\"count\">(%d)</span></a> |</li>", 'page=' . self::PLUGIN_SLUG . '&actio=' . self::PLUGIN_FONT_LIST, __('Used', self::PLUGIN_SLUG), isset($stats[0]) ? $stats[0]->qty : 0); printf("<li class='unused'><a href='admin.php?%s&f=unused' " . (isset($_GET['f']) && $_GET['f'] == 'unused' ? "class=\"current\"" : "") . ">%s <span class=\"count\">(%d)</span></a></li>", 'page=' . self::PLUGIN_SLUG . '&actio=' . self::PLUGIN_FONT_LIST, __('Unused', self::PLUGIN_SLUG), isset($stats[1]) ? $stats[1]->qty : 0); print "</ul>"; 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_LIST); print "</form>"; printf("<form id=\"posts-filter\" action=\"admin.php?page=%s&actio=%s&act=bulk\" method=\"post\">", self::PLUGIN_SLUG, self::PLUGIN_FONT_LIST); print "<div class=\"tablenav top\">"; print "<div class=\"alignleft actions\">"; print "\t<select name='action'>"; printf("\t\t<option value='-1' selected='selected'>%s</option>", __("Bulk actions", self::PLUGIN_SLUG)); printf("\t\t<option value='uninstall'>%s</option>", __("Uninstall", self::PLUGIN_SLUG)); print "\t</select>"; print "<input type=\"submit\" name=\"\" id=\"doaction\" class=\"button action\" value=\"" . __("Apply", self::PLUGIN_SLUG) . "\" />"; print "</div>"; $paginationcode = ''; printf("<div class='tablenav-pages'><span class=\"displaying-num\">%s</span>%s</div>", sprintf(_n('%d font', '%d fonts', isset($stats[2]) ? $stats[2]->qty : 0), isset($stats[2]) ? $stats[2]->qty : 0), $paginationcode); print "</div>"; self::IncludeCssForFonts(true); print '<table class="wp-list-table widefat fixed" cellspacing="0">'; print '<thead>'; print '<tr>'; print '<th scope=\'col\' id=\'cb\' class=\'manage-column column-cb check-column\' style=""><label class="screen-reader-text" for="cb-select-all-1">' . __('Select all', self::PLUGIN_SLUG) . '</label><input id="cb-select-all-1" type="checkbox" /></th>'; 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_LIST . '&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_LIST . '&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=\'cb\' class=\'manage-column column-cb check-column\' style=""><label class="screen-reader-text" for="cb-select-all-1">' . __('Select all', self::PLUGIN_SLUG) . '</label><input id="cb-select-all-1" type="checkbox" /></th>'; 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_LIST . '&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_LIST . '&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 ($installedFonts as $fnt) { print '<tr id="fnt-' . $fnt->id . '" class="alternate iedit" valign="top" style="font-family: ' . $fnt->name . ';">'; print '<th scope="row" class="check-column">'; print '<label class="screen-reader-text" for="cb-select-' . $fnt->id . '">' . sprintf('%s %s', __('Select', self::PLUGIN_SLUG), $fnt->name) . '</label>'; print '<input id="cb-select-' . $fnt->id . '" type="checkbox" name="font[]" value="' . $fnt->id . '" />'; print '<div class="locked-indicator"></div>'; print '</th>'; 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">'; if ($fnt->total_used == 0) { $onclick = ''; } else { $txt = sprintf(_n('This font is used in %d post. If you uninstall it this post will loose font styling.', 'This font is used in %d posts. If you uninstall it these posts will loose font styling.', $fnt->total_used), $fnt->total_used); $onclick = sprintf(' onclick="return confirm(\'%s\');"', $txt); } print '<span class=\'trash\'><a class=\'submitdelete\' title=\'' . __('Uninstall', self::PLUGIN_SLUG) . '\' href=\'' . admin_url('admin.php?page=' . self::PLUGIN_SLUG . '&actio=' . self::PLUGIN_FONT_LIST . '&id=' . $fnt->id . '&act=uninstall') . '\'' . $onclick . '>' . __('Uninstall', self::PLUGIN_SLUG) . '</a></span>'; print '</div>'; 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>'; print '</form>'; }