Skip to content

Instantly share code, notes, and snippets.

@shshaw shshaw/checklist.php
Created Sep 11, 2013

Embed
What would you like to do?
A simple checklist for your Wordpress pages to help you mark page completion. Drop this file in your main Wordpress directory and check off pages as you complete them. The script utilizes localStorage to save your checks. Very useful for Wordpress sites with a lot of pages.
<?php
/*////////////////////////////////////////
WORDPRESS PAGE CHECKLIST
////////////////////////////////////////*/
// Load WordPress
require_once( './wp/wp-load.php' );
?><html>
<head>
<title>CHECKLIST</title>
<style type="text/css">
body {
background: #EEE;
font: 300 16px/20px "Helvetica Neue", Helvetica, sans-serif;
color: #444;
}
a {
color: #666;
text-decoration: none;
}
a:hover,
a:focus {
text-decoration: underline;
}
ul, li {
margin: 0 20px;
padding: 0;
}
</style>
</head>
<body>
<h1><?php echo bloginfo('name'); ?> Page Checklist</h1>
<ul id="Checklist">
<?php
// List out all pages
wp_list_pages(array(
'depth' => 0,
'echo' => 1,
'title_li' => false,
'sort_column' => 'menu_order, post_title',
'link_hash' => false,
'link_before' => '<input type="checkbox" />',
));
?>
</ul>
<script type='text/javascript' src='//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js'></script>
<script type="text/javascript">
<!--
$("a").attr("target","_blank");
checkboxes = $("input[type='checkbox']");
checkboxes.each(function(){
checkbox = $(this);
parent = checkbox.closest(".page_item");
parentID = parent.attr("class").replace(/(.*?)page-item-([0-9]*)(.*?)$/g,"$2");
checkbox.attr("id","checkbox_"+parentID)
// console.log("parentID",parentID);
checkbox.click(function(){
checkbox = $(this);
if ( checkbox.is(':checked') ) {
localStorage.setItem(checkbox.attr("id"), "true");
// console.log("localstorage checked "+checkbox.attr("id"));
} else {
localStorage.setItem(checkbox.attr("id"), "false");
// console.log("localstorage unchecked "+checkbox.attr("id"));
}
});
getChecked = localStorage.getItem(checkbox.attr("id"));
if ( getChecked === "true" ) {
// console.log("its checked");
checkbox.attr('checked','checked');
}
});
-->
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.