class glm_blocks_front
{
+ /**
+ * pluginDirName
+ *
+ * @var mixed
+ * @access public
+ */
public $pluginDirName;
/**
$this->pluginDirName = $path;
}
+ /**
+ * Display the blocks
+ *
+ * Used in Preston feather it uses a default template to output the fetchAllBlocks
+ */
public function showBlocks()
{
$block = new glm_models_block($this->pluginDirName);
$block->displayBlocks();
}
+
+ /**
+ * Fetches the blocks into an array
+ *
+ * Now you can control how the block is output
+ *
+ * @return array
+ */
+ public function fetchAllBlocks()
+ {
+ $block = new glm_models_block($this->pluginDirName);
+ return $block->fetchAllBlocks();
+ }
}
<?php
+/**
+ * glm_models_block
+ *
+ * @package Gaslight Blocks Plugin
+ * @version //autogen//
+ * @copyright Copyright (c) 2010 All rights reserved.
+ * @author Steve Sutton <steve@gaslightmedia.com>
+ * @license PHP Version 5.5 {@link http://www.php.net/license/3_0.txt}
+ */
class glm_models_block
{
+ /**
+ * pluginDirName
+ *
+ * @var mixed
+ * @access public
+ */
public $pluginDirName;
+ /**
+ * __construct
+ *
+ * @param mixed $path
+ * @access public
+ * @return void
+ */
public function __construct($path)
{
$this->pluginDirName = $path;
add_action('pre_get_posts', array($this, 'sortQuery'));
}
+ /**
+ * sortQuery
+ *
+ * @param mixed $query
+ * @access public
+ * @return void
+ */
public function sortQuery($query)
{
if (is_admin() && !isset($_REQUEST['orderby'])) {
register_post_type(GLM_BLOCK_POST_TYPE, $args);
}
+ /**
+ * addMetaBoxes
+ *
+ * @access public
+ * @return void
+ */
public function addMetaBoxes()
{
add_meta_box(
);
}
+ /**
+ * metaBoxCallBack
+ *
+ * @param mixed $post
+ * @access public
+ * @return void
+ */
public function metaBoxCallBack($post)
{
$glm_block_url = ($post)
include $this->pluginDirName . 'views/admin/metaBoxes.php';
}
+ /**
+ * saveMetaBox
+ *
+ * @param mixed $post_id
+ * @access public
+ * @return void
+ */
public function saveMetaBox($post_id)
{
global $post;
update_post_meta($post->ID, 'glm_block_page', $_POST['glm_block_page']);
}
- public function displayBlocks()
+ /**
+ * fetchAllBlocks
+ *
+ * @access public
+ * @return void
+ */
+ public function fetchAllBlocks()
{
global $wpdb, $wp;
$args = array(
$blocks = get_posts($args);
foreach ($blocks as $block) {
$block->externalUrl = false;
- $custom = get_post_custom($block->ID);
+ $custom = get_post_custom($block->ID);
if ($custom['glm_block_url'][0] == 'page') {
$block->url = get_permalink($custom['glm_block_page'][0]);
}
$block->externalUrl = true;
}
}
+ $block->thumbnail = get_the_post_thumbnail(
+ $block->ID, GLM_BLOCK_POST_TYPE, array('class' => 'aligncenter')
+ );
+ }
+ return $blocks;
+ }
+
+ /**
+ * displayBlocks
+ *
+ * @access public
+ * @return void
+ */
+ public function displayBlocks()
+ {
+ $blocks = $this->fetchAllBlocks();
+ foreach ($blocks as $block) {
$block->thumbnail = get_the_post_thumbnail(
$block->ID, array(298, 228), array('class' => 'aligncenter')
);
include $this->pluginDirName . 'views/front/showBlocks.php';
}
+ /**
+ * addOrderColumn
+ *
+ * @param mixed $header_text_columns
+ * @access public
+ * @return void
+ */
function addOrderColumn($header_text_columns)
{
$header_text_columns['menu_order'] = "Order";
return $header_text_columns;
}
+ /**
+ * showOrderColumn
+ *
+ * @param mixed $name
+ * @access public
+ * @return void
+ */
function showOrderColumn($name)
{
global $post;
break;
}
}
+
+ /**
+ * orderSortable
+ *
+ * @param mixed $columns
+ * @access public
+ * @return void
+ */
function orderSortable($columns)
{
$columns['menu_order'] = 'menu_order';