/**
  * This method will switch module search results with posts the module is used in
  * @return void
  */
 public function moduleSearch()
 {
     global $wp_query;
     if (!$wp_query->is_search()) {
         return;
     }
     $searchResult = $wp_query->posts;
     foreach ($wp_query->posts as $key => $post) {
         // Continue if not a modularity post type
         if (substr($post->post_type, 0, 4) != 'mod-') {
             continue;
         }
         // Find module usage
         $usage = \Modularity\Module::getModuleUsage($post->ID);
         $usagePosts = array();
         foreach ($usage as $item) {
             $usagePosts[] = get_post($item->post_id);
         }
         $searchResult = $this->appendToArray($searchResult, $key, $usagePosts);
         unset($searchResult[$key]);
     }
     $wp_query->posts = array_values($searchResult);
 }
 /**
  * Get column width options
  * @return string Options markup
  */
 public function getWidthOptions()
 {
     $markup = '<option value="">' . __('Inherit', 'modularity') . '</option>' . "\n";
     foreach (\Modularity\Module::widthOptions() as $key => $value) {
         $markup .= '<option value="' . $key . '">' . $value . '</option>' . "\n";
     }
     return $markup;
 }
Exemple #3
0
    <label for="<?php 
echo $this->get_field_id('module_size');
?>
"><?php 
_e('Module width', 'modularity');
?>
:</label>
    <select class="widefat" name="<?php 
echo $this->get_field_name('module_size');
?>
" id="<?php 
echo $this->get_field_id('size');
?>
">
        <?php 
foreach (\Modularity\Module::widthOptions() as $key => $type) {
    ?>
            <option value="<?php 
    echo $key;
    ?>
" <?php 
    selected(isset($instance['module_size']) ? $instance['module_size'] : '', $key, true);
    ?>
><?php 
    echo $type;
    ?>
</option>
        <?php 
}
?>
    </select>