Plugin Directory

Changeset 1417575


Ignore:
Timestamp:
05/16/2016 12:44:14 AM (10 years ago)
Author:
ShinichiN
Message:

0.6. 0.5 was a mistaken update

Location:
dynamically-dynamic-sidebar
Files:
12 added
3 edited

Legend:

Unmodified
Added
Removed
  • dynamically-dynamic-sidebar/trunk/dynamically-dynamic-sidebar.php

    r1417568 r1417575  
    22/*
    33Plugin Name: Dynamically Dynamic Sidebar
    4 Version: 0.5
     4Version: 0.6
    55Description: This plugin enables you to create unlimited widget area and use them for posts, pages, categories, tags and so on.
    66Author: Shinichi Nishikawa
  • dynamically-dynamic-sidebar/trunk/inc/functions.php

    r1287029 r1417575  
    1818}
    1919
    20 // return: widget_id, widget_name and term object detemining the widget id.
    21 // Returns the FIRST FOUND widget area array.
     20/**
     21 * Returns an array of area FIRST FOUND.
     22 * If no area is assigned, returns false.
     23 *
     24 * @param  int   $post          post id
     25 * @return array $area_term_arr an array of widget_id, widget_name
     26                                and term object detemining the widget id.
     27 */
    2228function dds_get_widget_of_post_by_term( $post ) {
    2329
    2430    // マスター
    25     $terms     = array();
    26     $ancestors = array();
    27     $return    = array();
     31    $terms         = array();
     32    $ancestors     = array();
     33    $area_term_arr = array();
    2834
    2935    // 登録されているタクソノミ
     
    3339    foreach ( $taxonomies as $taxonomy ) {
    3440
    35         $temp = get_the_terms( $post, $taxonomy ); // タームを取得
     41        $term_obj = get_the_terms( $post, $taxonomy ); // タームを取得
    3642
    3743        // タームに属していればマスターに入れる
    38         if ( is_array( $temp ) ) {
    39             $terms = array_merge( $terms, $temp );
     44        if ( is_array( $term_obj ) ) {
     45            $terms = array_merge( $terms, $term_obj );
    4046        }
    4147
     
    4349
    4450    // 直接のタームをチェック
    45     $return = dds_check_term_arrays_allocated_area( $terms );
     51    $area_term_arr = dds_check_term_arrays_allocated_area( $terms );
    4652
    47     if ( $return ) {
    48         return $return;
     53    if ( $area_term_arr ) {
     54        return $area_term_arr;
    4955    }
    5056
     
    5258    foreach ( $terms as $t ) {
    5359
    54         $temp = get_ancestors( $t->term_id, $t->taxonomy );
     60        $ancestor_term_id_arr = get_ancestors( $t->term_id, $t->taxonomy );
    5561
    56         if ( is_array( $temp ) ) {
    57             $ancestors = array_merge( $ancestors, $temp );
     62        if ( is_array( $ancestor_term_id_arr ) ) {
     63            foreach ( $ancestor_term_id_arr as $a_id ) {
     64                $term_obj = get_term_by( 'id', $a_id, $t->taxonomy );
     65                $ancestors[] = $term_obj;
     66            }
    5867        }
    5968
    6069    }
    6170
    62     $return = dds_check_term_arrays_allocated_area( $ancestors );
     71    $area_term_arr = dds_check_term_arrays_allocated_area( $ancestors );
    6372
    64     if ( $return ) {
    65         return $return;
     73    if ( $area_term_arr ) {
     74        return $area_term_arr;
    6675    } else {
    6776        return false;
     
    7079}
    7180
    72 // タームのオブジェクト/あるいはIDの配列を受けて、最初に返ってきたエリアを返す関数
     81/**
     82 * Given an array of term objects,
     83 * returns FIRST FOUND widget area info.
     84 *
     85 *
     86 *
     87 * @param  int|object $terms         term id or term object
     88 * @return array      $area_term_arr $area_term_arr an array of widget_id, widget_name
     89                                and term object detemining the widget id.
     90 */
    7391function dds_check_term_arrays_allocated_area( $terms ) {
    7492
     
    93111            $allocatable_widgets  = get_option( 'dds_sidebars' );
    94112
    95             $return["area-id"]   = $area_id;
    96             $return["area-name"] = $allocatable_widgets[$area_id];
    97             $return["term"]      = $t;
     113            $area_term_arr["area-id"]   = $area_id;
     114            $area_term_arr["area-name"] = $allocatable_widgets[$area_id];
     115            $area_term_arr["term"]      = $t;
    98116
    99117            break;
     
    103121    }
    104122
    105     if ( isset( $return ) && is_array( $return ) ) {
    106         return $return;
     123    if ( isset( $area_term_arr ) && is_array( $area_term_arr ) ) {
     124        return $area_term_arr;
    107125    } else {
    108126        return false;
  • dynamically-dynamic-sidebar/trunk/readme.txt

    r1417568 r1417575  
    44Requires at least: 4.4
    55Tested up to: 4.5.2
    6 Stable tag: 0.5
     6Stable tag: 0.6
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
Note: See TracChangeset for help on using the changeset viewer.