Plugin Directory

Changeset 2913641


Ignore:
Timestamp:
05/17/2023 12:01:28 PM (3 years ago)
Author:
akdevs
Message:

freemius fix

Location:
genealogical-tree
Files:
355 added
11 edited

Legend:

Unmodified
Added
Removed
  • genealogical-tree/trunk/README.txt

    r2891385 r2913641  
    44Requires at least: 4.4
    55Tested up to: 6.2
    6 Stable tag: 2.2.0.7
     6Stable tag: 2.2.0.8
    77License: GPLv2
    88
  • genealogical-tree/trunk/admin/class-genealogical-tree-admin.php

    r2891385 r2913641  
    425425    public function render_meta_box_member_info( $post )
    426426    {
    427         $name = ( get_post_meta( $post->ID, 'full_name', true ) ? get_post_meta( $post->ID, 'full_name', true ) : '' );
    428         $givn = ( get_post_meta( $post->ID, 'givn', true ) ? get_post_meta( $post->ID, 'givn', true ) : '' );
    429         $surn = ( get_post_meta( $post->ID, 'surn', true ) ? get_post_meta( $post->ID, 'surn', true ) : '' );
    430         $names = ( get_post_meta( $post->ID, 'names' ) ? get_post_meta( $post->ID, 'names' ) : array( array(
    431             'name' => $name,
    432             'npfx' => '',
    433             'givn' => $givn,
    434             'nick' => '',
    435             'spfx' => '',
    436             'surn' => $surn,
    437             'nsfx' => '',
    438         ) ) );
    439         $sex = get_post_meta( $post->ID, 'sex', true );
    440         $event = ( get_post_meta( $post->ID, 'even' ) ? get_post_meta( $post->ID, 'even' ) : array() );
    441         $birt = array();
    442         $deat = array();
    443         $fams = ( get_post_meta( $post->ID, 'fams' ) ? get_post_meta( $post->ID, 'fams' ) : array( array(
    444             'fams' => '',
    445         ) ) );
    446         $famc = ( get_post_meta( $post->ID, 'famc' ) ? get_post_meta( $post->ID, 'famc' ) : array( array(
    447             'famc' => '',
    448             'pedi' => '',
    449         ) ) );
    450         $slgc = ( get_post_meta( $post->ID, 'slgc' ) ? get_post_meta( $post->ID, 'slgc' ) : array( array(
    451             'famc' => '',
    452             'date' => '',
    453             'plac' => '',
    454         ) ) );
    455         foreach ( $names as $key => &$name ) {
    456             if ( $name && !is_array( $name ) ) {
    457                 $name = array(
    458                     'name' => $name,
    459                     'npfx' => '',
    460                     'givn' => '',
    461                     'nick' => '',
    462                     'spfx' => '',
    463                     'surn' => '',
    464                     'nsfx' => '',
    465                 );
    466             }
    467         }
    468         foreach ( $names as $key => $value ) {
    469             if ( !isset( $value['name'] ) ) {
    470                 unset( $names[$key] );
    471             }
    472         }
    473         foreach ( $event as $key => $value ) {
    474             $event[$key]['tag'] = strtoupper( $value['tag'] );
    475         }
    476         foreach ( $event as $key => $value ) {
    477            
    478             if ( 'BIRT' === (string) $value['tag'] ) {
    479                 $birt[] = $value;
    480                 unset( $event[$key] );
    481             }
    482            
    483            
    484             if ( 'DEAT' === (string) $value['tag'] ) {
    485                 $deat[] = $value;
    486                 unset( $event[$key] );
    487             }
    488        
    489         }
    490         if ( empty($birt) ) {
    491             $birt = array( array(
    492                 'tag'  => 'BIRT',
    493                 'even' => '',
    494                 'type' => 'BIRT',
    495                 'date' => '',
    496                 'plac' => '',
    497             ) );
    498         }
    499         if ( empty($deat) ) {
    500             $deat = array( array(
    501                 'tag'  => 'DEAT',
    502                 'even' => '',
    503                 'type' => 'DEAT',
    504                 'date' => '',
    505                 'plac' => '',
    506             ) );
    507         }
    508         if ( empty($event) ) {
    509             $event[0] = array(
    510                 'tag'  => '',
    511                 'even' => '',
    512                 'type' => '',
    513                 'date' => '',
    514                 'plac' => '',
    515             );
    516         }
    517         // Fix fams.
    518         $is_duplicate_fams = array();
    519         foreach ( $fams as $key => $value ) {
    520             if ( !is_array( $value ) ) {
    521                 unset( $fams[$key] );
    522             }
    523            
    524             if ( is_array( $value ) ) {
    525                 if ( in_array( $value['fams'], $is_duplicate_fams, true ) ) {
    526                     unset( $fams[$key] );
    527                 }
    528                 array_push( $is_duplicate_fams, $value['fams'] );
    529             }
    530        
    531         }
    532         foreach ( $fams as $key => $fam ) {
    533             if ( isset( $fam['fams'] ) && $fam['fams'] && is_array( $fam['fams'] ) ) {
    534                 $fam['fams'] = $fam['fams']['fams'];
    535             }
    536             $husb = (int) get_post_meta( $fam['fams'], 'husb', true );
    537             $wife = (int) get_post_meta( $fam['fams'], 'wife', true );
    538             $fams[$key]['spouse'] = ( $husb === (int) $post->ID ? $wife : $husb );
    539             $fams[$key]['chil'] = ( get_post_meta( $fam['fams'], 'chil' ) ? get_post_meta( $fam['fams'], 'chil' ) : array() );
    540             $fams[$key]['event'] = ( get_post_meta( $fam['fams'], 'even' ) ? get_post_meta( $fam['fams'], 'even' ) : array( array(
    541                 'tag'  => '',
    542                 'even' => '',
    543                 'type' => '',
    544                 'date' => '',
    545                 'plac' => '',
    546             ) ) );
    547         }
    548         // Fix famc.
    549         $is_duplicate_famc = array();
    550         foreach ( $famc as $key => $value ) {
    551             if ( !is_array( $value ) ) {
    552                 unset( $famc[$key] );
    553             }
    554            
    555             if ( is_array( $value ) ) {
    556                 if ( in_array( $value['famc'], $is_duplicate_famc, true ) ) {
    557                     unset( $famc[$key] );
    558                 }
    559                 array_push( $is_duplicate_famc, $value['famc'] );
    560             }
    561        
    562         }
    563         foreach ( $famc as $key => $fam ) {
    564             if ( isset( $fam['famc'] ) && $fam['famc'] && is_array( $fam['famc'] ) ) {
    565                 $fam['famc'] = $fam['famc']['famc'];
    566             }
    567             $famc[$key]['husb'] = get_post_meta( $fam['famc'], 'husb', true );
    568             $famc[$key]['wife'] = get_post_meta( $fam['famc'], 'wife', true );
    569             $famc[$key]['chil'] = ( get_post_meta( $fam['famc'], 'chil' ) ? get_post_meta( $fam['famc'], 'chil' ) : array() );
    570             foreach ( $slgc as $key_slgc => $value ) {
    571                
    572                 if ( (int) $fam['famc'] === (int) $value['famc'] ) {
    573                     $famc[$key]['slgc'] = current( $slgc );
    574                 } else {
    575                     $famc[$key]['slgc'] = array(
    576                         'famc' => '',
    577                         'date' => '',
    578                         'plac' => '',
    579                     );
    580                 }
    581            
    582             }
    583         }
    584427        require_once plugin_dir_path( __FILE__ ) . 'partials/genealogical-tree-meta-member-info.php';
    585428    }
     
    908751           
    909752            if ( $wife || $husb ) {
    910                 $family_id = $this->find_or_create_family( $wife, $husb, array( $post_id ) );
     753                $chills = array( array(
     754                    'id'   => $post_id,
     755                    'pedi' => $parent['pedi'],
     756                ) );
     757                $family_id = $this->find_or_create_family( $wife, $husb, $chills );
    911758                array_push( $famc_new_array, $family_id );
    912759                $famc = ( get_post_meta( $post_id, 'famc' ) ? get_post_meta( $post_id, 'famc' ) : array() );
     
    931778                    array_push( $indis, $husb );
    932779                }
     780                $this->repear_family( $family_id );
    933781            }
    934782       
     
    947795        foreach ( $spouses as $key => $spouse ) {
    948796            $order = ( isset( $spouse['order'] ) ? $spouse['order'] : 0 );
    949             $chil = ( isset( $spouse['chil'] ) ? array_filter( array_unique( $spouse['chil'] ) ) : array() );
     797            $chil = ( isset( $spouse['chil'] ) ? $spouse['chil'] : array() );
    950798           
    951799            if ( $spouse['id'] || !empty($chil) ) {
     
    975823                        array_push( $indis, $husb );
    976824                    }
     825                    $this->repear_family( $family_id );
    977826                }
    978827           
     
    1006855            add_post_meta( $post_id, 'slgc', $slgc_new );
    1007856        }
    1008    
     857       
     858        $this->repear_member( array( $post_id ) );
    1009859    }
    1010860   
     
    12001050        switch ( $column ) {
    12011051            case 'shortcode':
    1202                 echo  sprintf( '<input type="text" readonly value="[tree id=%1$s]">', esc_attr( $post_id ) ) ;
     1052                echo  sprintf( '<input style="max-width:%2$s" type="text" readonly value="[tree id=%1$s]">', esc_attr( $post_id ), esc_attr( '100%' ) ) ;
    12031053                break;
    12041054        }
     
    14631313           
    14641314            if ( is_array( $chil ) && !empty($chil) ) {
    1465                 foreach ( $chil as $key => $ch ) {
    1466                     // Manage family.
    1467                     /* Checking if the child is already in the family of parents. If not, it adds the child to the family. */
    1468                     $current_chil = ( get_post_meta( $family_id, 'chil' ) ? get_post_meta( $family_id, 'chil' ) : array() );
    1469                     if ( !in_array( (string) $ch, $current_chil, true ) ) {
    1470                         add_post_meta( $family_id, 'chil', $ch );
    1471                     }
    1472                     /* Get parent families. */
    1473                     $famc = ( get_post_meta( $ch, 'famc' ) ? get_post_meta( $ch, 'famc' ) : array() );
    1474                     /* Prepare for checking. */
    1475                     foreach ( $famc as $value ) {
    1476                         if ( isset( $value['famc'] ) && $value['famc'] ) {
    1477                             $famc[] = (int) $value['famc'];
     1315                foreach ( $chil as $ch ) {
     1316                   
     1317                    if ( is_array( $ch ) ) {
     1318                        // Manage family.
     1319                        /* Checking if the child is already in the family of parents. If not, it adds the child to the family. */
     1320                        $current_chil = ( get_post_meta( $family_id, 'chil' ) ? get_post_meta( $family_id, 'chil' ) : array() );
     1321                        if ( !in_array( (string) $ch['id'], $current_chil, true ) ) {
     1322                            add_post_meta( $family_id, 'chil', $ch['id'] );
    14781323                        }
    1479                     }
    1480                     /*
    1481                     Checking to see if the family_ID is in the array of parents families. If it is not, it adds it to the
    1482                     families.
    1483                     */
    1484                     if ( !in_array( (int) $family_id, $famc, true ) ) {
    1485                         add_post_meta( $ch, 'famc', array(
    1486                             'famc' => $family_id,
    1487                             'pedi' => '',
    1488                         ) );
    1489                     }
     1324                        /* Get parent families. */
     1325                        $famc = ( get_post_meta( $ch['id'], 'famc' ) ? get_post_meta( $ch['id'], 'famc' ) : array() );
     1326                        /* Prepare for checking. */
     1327                        foreach ( $famc as $value ) {
     1328                            if ( isset( $value['famc'] ) && $value['famc'] ) {
     1329                                $famc[] = (int) $value['famc'];
     1330                            }
     1331                        }
     1332                        /*
     1333                        Checking to see if the family_ID is in the array of parents families. If it is not, it adds it to the
     1334                        families.
     1335                        */
     1336                        if ( !in_array( (int) $family_id, $famc, true ) ) {
     1337                            add_post_meta( $ch['id'], 'famc', array(
     1338                                'famc' => $family_id,
     1339                                'pedi' => ( $ch['pedi'] ? $ch['pedi'] : '' ),
     1340                            ) );
     1341                        }
     1342                    }
     1343               
    14901344                }
    14911345            }
     
    24092263                    if ( isset( $family['chil'] ) && $family['chil'] && !empty($family['chil']) && is_array( $family['chil'] ) ) {
    24102264                        foreach ( $family['chil'] as $key => $chi ) {
    2411                             $chil[] = $person_map[$chi];
     2265                            $chil[] = $person_map[$chi['id']];
    24122266                        }
    24132267                    }
     
    25602414        update_option( 'genealogical_tree_last_imported_group', $family_group_id );
    25612415    }
     2416   
     2417    /**
     2418     * It deletes a family if it has no husband, wife, or children
     2419     *
     2420     * @param family_id The ID of the family you want to check.
     2421     */
     2422    public function repear_family( $family_id )
     2423    {
     2424        $chil = ( get_post_meta( $family_id, 'chil' ) ? get_post_meta( $family_id, 'chil' ) : array() );
     2425        $wife = get_post_meta( $family_id, 'wife', true );
     2426        $husb = get_post_meta( $family_id, 'husb', true );
     2427        $error = array();
     2428        foreach ( $chil as $key => $ch ) {
     2429           
     2430            if ( is_array( $ch ) || !is_numeric( $ch ) ) {
     2431                $error[] = $ch;
     2432                unset( $chil[$key] );
     2433            }
     2434       
     2435        }
     2436        $chil = array_unique( $chil );
     2437       
     2438        if ( !empty($error) ) {
     2439            delete_post_meta( $family_id, 'chil' );
     2440            foreach ( $chil as $key => $ch ) {
     2441                add_post_meta( $family_id, 'chil', $ch );
     2442            }
     2443        }
     2444       
     2445        if ( $wife && !$husb && !$chil || $husb && !$wife && !$chil || $chil && !$husb && !$wife || !$wife && !$husb && !$chil ) {
     2446            wp_delete_post( $family_id );
     2447        }
     2448        $member_ids = array();
     2449        $member_ids[] = $wife;
     2450        $member_ids[] = $husb;
     2451        foreach ( $chil as $key => $ch ) {
     2452            $member_ids[] = $ch;
     2453        }
     2454        $this->repear_member( $member_ids );
     2455    }
     2456   
     2457    /**
     2458     * It removes any family relationships that are not associated with a valid family post
     2459     *
     2460     * @param array $member_ids An array of member IDs to be repaired.
     2461     */
     2462    public function repear_member( $member_ids )
     2463    {
     2464        foreach ( $member_ids as $key => $member ) {
     2465            $famc = ( get_post_meta( $member, 'famc' ) ? get_post_meta( $member, 'famc' ) : array() );
     2466            $error = array();
     2467            foreach ( $famc as $key => $fam ) {
     2468               
     2469                if ( !get_post( $fam['famc'] ) ) {
     2470                    $error[] = $fam;
     2471                    unset( $famc[$key] );
     2472                }
     2473           
     2474            }
     2475           
     2476            if ( !empty($error) ) {
     2477                delete_post_meta( $member, 'famc' );
     2478                foreach ( $famc as $key => $fam ) {
     2479                    # code...
     2480                    add_post_meta( $member, 'famc', $fam );
     2481                }
     2482            }
     2483           
     2484            $fams = ( get_post_meta( $member, 'fams' ) ? get_post_meta( $member, 'fams' ) : array() );
     2485            $error = array();
     2486            foreach ( $fams as $key => $fam ) {
     2487               
     2488                if ( !get_post( $fam['fams'] ) ) {
     2489                    $error[] = $fam;
     2490                    unset( $fams[$key] );
     2491                }
     2492           
     2493            }
     2494           
     2495            if ( !empty($error) ) {
     2496                delete_post_meta( $member, 'fams' );
     2497                foreach ( $fams as $key => $fam ) {
     2498                    add_post_meta( $member, 'fams', $fam );
     2499                }
     2500            }
     2501       
     2502        }
     2503    }
     2504   
     2505    /**
     2506     * The function `tree_family_and_root_columns()` is a filter that adds two columns to the array of
     2507     * columns that are displayed in the admin table
     2508     *
     2509     * the above hook will add columns only for default 'post' post type, for CPT:
     2510     * manage_{POST TYPE NAME}_posts_columns
     2511     *
     2512     * @param array $column_array This is the array of columns that are currently being displayed.
     2513     *
     2514     * @return array The array of columns.
     2515     */
     2516    public function tree_family_and_root_columns( $column_array )
     2517    {
     2518        $column_array['family'] = 'Family';
     2519        $column_array['root'] = 'Root';
     2520        // the above code will add columns at the end of the array
     2521        // if you want columns to be added in another order, use array_slice()
     2522        return $column_array;
     2523    }
     2524   
     2525    /**
     2526     * It adds two columns to the admin page for the custom post type, and populates them with the values
     2527     * of the custom fields 'family' and 'root'
     2528     *
     2529     * @param string $column_name the name of the column you want to populate
     2530     * @param int    $post_id The ID of the post being displayed
     2531     */
     2532    public function tree_populate_family_and_root_columns( $column_name, $post_id )
     2533    {
     2534        $tree = get_post_meta( $post_id, 'tree', true );
     2535        $tree = ( $tree ? $tree : array() );
     2536        $family = ( isset( $tree['family'] ) && $tree['family'] ? $tree['family'] : '' );
     2537        $root = ( isset( $tree['root'] ) && $tree['root'] ? $tree['root'] : '' );
     2538        // if you have to populate more that one columns, use switch()
     2539        switch ( $column_name ) {
     2540            case 'family':
     2541                $title = ( $family ? ' - ' . get_term( $family )->name : '' );
     2542                echo  '<span>' . $family . '</span>' . $family . $title ;
     2543                break;
     2544            case 'root':
     2545                $title = ( $root ? ' - ' . get_the_title( $root ) : '' );
     2546                echo  '<span>' . $root . '</span>' . $title ;
     2547                break;
     2548        }
     2549    }
     2550   
     2551    /**
     2552     * It adds a dropdown to the quick edit screen for the custom post type
     2553     *
     2554     * @param string $column_name The name of the column.
     2555     * @param string $post_type The post type slug.
     2556     */
     2557    public function tree_quick_edit_fields( $column_name, $post_type )
     2558    {
     2559        switch ( $column_name ) {
     2560            case 'family':
     2561                ?>
     2562                    <fieldset class="inline-edit-col-left">
     2563
     2564                        <div class="inline-edit-col">
     2565                            <label>
     2566                                <span class="title">Select Family</span>
     2567                                <select id="family" name="family">
     2568                                    <option value="">
     2569                                        <?php
     2570                esc_html_e( 'Select Family', 'genealogical-tree' );
     2571                ?>
     2572                                    </option>
     2573                                    <?php
     2574                $terms = $this->get_gt_family();
     2575                foreach ( $terms as $key => $fg_term ) {
     2576                    ?>
     2577                                        <option value="<?php
     2578                    echo  esc_attr( $fg_term->term_id ) ;
     2579                    ?>">
     2580                                            <?php
     2581                    echo  esc_html( $fg_term->term_id ) ;
     2582                    ?> - <?php
     2583                    echo  esc_html( $fg_term->name ) ;
     2584                    ?>
     2585                                        </option>
     2586                                        <?php
     2587                }
     2588                ?>
     2589                                </select>
     2590                            </label>
     2591                        </div>
     2592
     2593                        <?php
     2594                break;
     2595            case 'root':
     2596                ?>
     2597                        <div class="inline-edit-col">
     2598                            <label>
     2599                                <span class="title">Select Root</span>
     2600                                <select id="root" name="root">
     2601                                    <option value="">
     2602                                        <?php
     2603                esc_html_e( 'Select Root', 'genealogical-tree' );
     2604                ?>
     2605                                    </option>
     2606                                    <?php
     2607                $members = $this->get_gt_member();
     2608                foreach ( $members as $key => $member ) {
     2609                    $term_list = wp_get_post_terms( $member->ID, 'gt-family-group', array(
     2610                        'fields' => 'ids',
     2611                    ) );
     2612                    $term_list = implode( ',', $term_list );
     2613                    ?>
     2614                                        <option data-famly="<?php
     2615                    echo  esc_attr( $term_list ) ;
     2616                    ?>" value="<?php
     2617                    echo  esc_attr( $member->ID ) ;
     2618                    ?>">
     2619                                            <?php
     2620                    echo  esc_html( $member->ID ) ;
     2621                    ?> - <?php
     2622                    echo  esc_html( $member->post_title ) ;
     2623                    ?>
     2624                                        </option>
     2625                                    <?php
     2626                }
     2627                ?>
     2628                                </select>
     2629                            </label>
     2630                        </div>
     2631
     2632                    </fieldset>
     2633                <?php
     2634                break;
     2635        }
     2636    }
     2637   
     2638    /**
     2639     * If the nonce is valid, update the family and root post meta
     2640     *
     2641     * @param $post_id $post_id The ID of the post being edited.
     2642     *
     2643     * @return mixed the value of the variable .
     2644     */
     2645    public function tree_quick_edit_save( $post_id )
     2646    {
     2647        // Check inlint edit nonce.
     2648        if ( !isset( $_POST['_inline_edit'] ) || isset( $_POST['_inline_edit'] ) && !wp_verify_nonce( $_POST['_inline_edit'], 'inlineeditnonce' ) ) {
     2649            return;
     2650        }
     2651        $tree = get_post_meta( $post_id, 'tree', true );
     2652        $tree = ( $tree ? $tree : array() );
     2653        $family = ( !empty($_POST['family']) ? sanitize_text_field( $_POST['family'] ) : '' );
     2654        $root = ( !empty($_POST['root']) ? sanitize_text_field( $_POST['root'] ) : '' );
     2655        $tree['family'] = $family;
     2656        $tree['root'] = $root;
     2657        update_post_meta( $post_id, 'tree', $tree );
     2658    }
     2659   
     2660    /**
     2661     * It returns an array of all the terms in the taxonomy 'gt-family-group' that are associated with the
     2662     * current user
     2663     *
     2664     * @return array An array of terms.
     2665     */
     2666    public function get_gt_family()
     2667    {
     2668        $meta_query = array( array(
     2669            'key'     => 'created_by',
     2670            'value'   => get_current_user_id(),
     2671            'compare' => '=',
     2672        ) );
     2673        if ( current_user_can( 'gt_manager' ) || current_user_can( 'editor' ) || current_user_can( 'administrator' ) ) {
     2674            $meta_query = array();
     2675        }
     2676        $terms = get_terms( array(
     2677            'taxonomy'   => 'gt-family-group',
     2678            'hide_empty' => false,
     2679            'meta_query' => $meta_query,
     2680        ) );
     2681        if ( is_wp_error( $terms ) ) {
     2682            $terms = array();
     2683        }
     2684        return $terms;
     2685    }
     2686   
     2687    /**
     2688     * It gets all the posts of type `gt-member` that the current user is the author of, and then gets all
     2689     * the posts of type `gt-member` that the current user is allowed to use, and then merges the two
     2690     * arrays and sorts them by ID
     2691     *
     2692     * @return array An array of member posts.
     2693     */
     2694    public function get_gt_member()
     2695    {
     2696        $args = array(
     2697            'post_type'      => 'gt-member',
     2698            'posts_per_page' => -1,
     2699            'fields'         => 'ids, post_title',
     2700            'author'         => get_current_user_id(),
     2701            'order_by'       => 'ID',
     2702        );
     2703        if ( current_user_can( 'gt_manager' ) || current_user_can( 'editor' ) || current_user_can( 'administrator' ) ) {
     2704            unset( $args['author'] );
     2705        }
     2706        $members = get_posts( $args );
     2707        $args = array(
     2708            'numberposts' => -1,
     2709            'post_type'   => 'gt-member',
     2710            'fields'      => 'ids, post_title',
     2711            'order_by'    => 'ID',
     2712            'meta_query'  => array( array(
     2713            'key'     => 'can_use',
     2714            'value'   => get_current_user_id(),
     2715            'compare' => 'IN',
     2716        ) ),
     2717        );
     2718        $members = array_merge( $members, get_posts( $args ) );
     2719        usort( $members, array( $this, 'sort_member_posts' ) );
     2720        return $members;
     2721    }
    25622722
    25632723}
  • genealogical-tree/trunk/admin/js/genealogical-tree-admin.js

    r2862583 r2913641  
    189189        });
    190190    });
     191    jQuery( function( $ ){
     192        if (typeof inlineEditPost !== 'undefined') {
     193            const wp_inline_edit_function = inlineEditPost.edit;
     194            inlineEditPost.edit = function( post_id ) {
     195                wp_inline_edit_function.apply( this, arguments );
     196                if ( typeof( post_id ) == 'object' ) {
     197                    post_id = parseInt( this.getId( post_id ) );
     198                }
     199                const edit_row = $( '#edit-' + post_id )
     200                const post_row = $( '#post-' + post_id )
     201                const family = $( '.column-family', post_row ).find('span').text()
     202                const root = $( '.column-root', post_row ).find('span').text()
     203
     204                $( 'select[name="family"]', edit_row ).val( family );
     205                $( 'select[name="root"]', edit_row ).val( root );
     206            }
     207        }
     208    })
     209
    191210})(jQuery);
  • genealogical-tree/trunk/admin/partials/genealogical-tree-meta-member-info.php

    r2862583 r2913641  
    1212 * @subpackage Genealogical_Tree/admin/partials
    1313 */
    14 ?>
    15 
    16 <?php
    17 if ( gt_fs()->is_not_paying() && !gt_fs()->is_trial() ) {
    18     ?>
    19 <style type="text/css">
    20     .gta-table .repetead-field .clone,
    21     .gta-table .repetead-field .delete {
    22         display: none;
    23     }
    24 </style>
    25 <?php
     14$name = ( get_post_meta( $post->ID, 'full_name', true ) ? get_post_meta( $post->ID, 'full_name', true ) : '' );
     15$givn = ( get_post_meta( $post->ID, 'givn', true ) ? get_post_meta( $post->ID, 'givn', true ) : '' );
     16$surn = ( get_post_meta( $post->ID, 'surn', true ) ? get_post_meta( $post->ID, 'surn', true ) : '' );
     17$names = ( get_post_meta( $post->ID, 'names' ) ? get_post_meta( $post->ID, 'names' ) : array( array(
     18    'name' => $name,
     19    'npfx' => '',
     20    'givn' => $givn,
     21    'nick' => '',
     22    'spfx' => '',
     23    'surn' => $surn,
     24    'nsfx' => '',
     25) ) );
     26$sex = get_post_meta( $post->ID, 'sex', true );
     27$event = ( get_post_meta( $post->ID, 'even' ) ? get_post_meta( $post->ID, 'even' ) : array() );
     28$birt = array();
     29$deat = array();
     30$fams = ( get_post_meta( $post->ID, 'fams' ) ? get_post_meta( $post->ID, 'fams' ) : array( array(
     31    'fams' => '',
     32) ) );
     33$famc = ( get_post_meta( $post->ID, 'famc' ) ? get_post_meta( $post->ID, 'famc' ) : array( array(
     34    'famc' => '',
     35    'pedi' => '',
     36) ) );
     37$slgc = ( get_post_meta( $post->ID, 'slgc' ) ? get_post_meta( $post->ID, 'slgc' ) : array( array(
     38    'famc' => '',
     39    'date' => '',
     40    'plac' => '',
     41) ) );
     42foreach ( $names as $key => &$name ) {
     43    if ( $name && !is_array( $name ) ) {
     44        $name = array(
     45            'name' => $name,
     46            'npfx' => '',
     47            'givn' => '',
     48            'nick' => '',
     49            'spfx' => '',
     50            'surn' => '',
     51            'nsfx' => '',
     52        );
     53    }
     54}
     55foreach ( $names as $key => $value ) {
     56    if ( !isset( $value['name'] ) ) {
     57        unset( $names[$key] );
     58    }
     59}
     60foreach ( $event as $key => $value ) {
     61    $event[$key]['tag'] = strtoupper( $value['tag'] );
     62}
     63foreach ( $event as $key => $value ) {
     64   
     65    if ( 'BIRT' === (string) $value['tag'] ) {
     66        $birt[] = $value;
     67        unset( $event[$key] );
     68    }
     69   
     70   
     71    if ( 'DEAT' === (string) $value['tag'] ) {
     72        $deat[] = $value;
     73        unset( $event[$key] );
     74    }
     75
     76}
     77if ( empty($birt) ) {
     78    $birt = array( array(
     79        'tag'  => 'BIRT',
     80        'even' => '',
     81        'type' => 'BIRT',
     82        'date' => '',
     83        'plac' => '',
     84    ) );
     85}
     86if ( empty($deat) ) {
     87    $deat = array( array(
     88        'tag'  => 'DEAT',
     89        'even' => '',
     90        'type' => 'DEAT',
     91        'date' => '',
     92        'plac' => '',
     93    ) );
     94}
     95if ( empty($event) ) {
     96    $event[0] = array(
     97        'tag'  => '',
     98        'even' => '',
     99        'type' => '',
     100        'date' => '',
     101        'plac' => '',
     102    );
     103}
     104// Fix fams.
     105$is_duplicate_fams = array();
     106foreach ( $fams as $key => $value ) {
     107    if ( !is_array( $value ) ) {
     108        unset( $fams[$key] );
     109    }
     110   
     111    if ( is_array( $value ) ) {
     112        if ( in_array( $value['fams'], $is_duplicate_fams, true ) ) {
     113            unset( $fams[$key] );
     114        }
     115        array_push( $is_duplicate_fams, $value['fams'] );
     116    }
     117
     118}
     119foreach ( $fams as $key => $fam ) {
     120    if ( isset( $fam['fams'] ) && $fam['fams'] && is_array( $fam['fams'] ) ) {
     121        $fam['fams'] = $fam['fams']['fams'];
     122    }
     123    $husb = (int) get_post_meta( $fam['fams'], 'husb', true );
     124    $wife = (int) get_post_meta( $fam['fams'], 'wife', true );
     125    $fams[$key]['spouse'] = ( $husb === (int) $post->ID ? $wife : $husb );
     126    $fams[$key]['chil'] = ( get_post_meta( $fam['fams'], 'chil' ) ? get_post_meta( $fam['fams'], 'chil' ) : array() );
     127    $fams[$key]['event'] = ( get_post_meta( $fam['fams'], 'even' ) ? get_post_meta( $fam['fams'], 'even' ) : array( array(
     128        'tag'  => '',
     129        'even' => '',
     130        'type' => '',
     131        'date' => '',
     132        'plac' => '',
     133    ) ) );
     134}
     135// Fix famc.
     136$is_duplicate_famc = array();
     137foreach ( $famc as $key => $value ) {
     138    if ( !is_array( $value ) ) {
     139        unset( $famc[$key] );
     140    }
     141   
     142    if ( is_array( $value ) ) {
     143        if ( in_array( $value['famc'], $is_duplicate_famc, true ) ) {
     144            unset( $famc[$key] );
     145        }
     146        array_push( $is_duplicate_famc, $value['famc'] );
     147    }
     148
     149}
     150foreach ( $famc as $key => $fam ) {
     151    if ( isset( $fam['famc'] ) && $fam['famc'] && is_array( $fam['famc'] ) ) {
     152        $fam['famc'] = $fam['famc']['famc'];
     153    }
     154    $famc[$key]['husb'] = get_post_meta( $fam['famc'], 'husb', true );
     155    $famc[$key]['wife'] = get_post_meta( $fam['famc'], 'wife', true );
     156    $famc[$key]['chil'] = ( get_post_meta( $fam['famc'], 'chil' ) ? get_post_meta( $fam['famc'], 'chil' ) : array() );
     157    foreach ( $slgc as $key_slgc => $value ) {
     158       
     159        if ( (int) $fam['famc'] === (int) $value['famc'] ) {
     160            $famc[$key]['slgc'] = current( $slgc );
     161        } else {
     162            $famc[$key]['slgc'] = array(
     163                'famc' => '',
     164                'date' => '',
     165                'plac' => '',
     166            );
     167        }
     168   
     169    }
    26170}
    27171$ref_id = ( get_post_meta( get_the_ID(), 'ref_id', true ) ? get_post_meta( get_the_ID(), 'ref_id', true ) : 'I' . get_the_ID() );
     
    33177$unknowns = $useable_members['unknowns'];
    34178?>
     179
     180<?php
     181if ( gt_fs()->is_not_paying() && !gt_fs()->is_trial() ) {
     182    ?>
     183    <style type="text/css">
     184    .gta-table .repetead-field .clone,
     185    .gta-table .repetead-field .delete {
     186        display: none;
     187    }
     188    </style>
     189<?php
     190}
     191?>
     192
    35193<div class="gta-container">
    36194    <?php
     
    9401098                                                    <?php
    9411099    foreach ( $fam['chil'] as $key => $chil ) {
     1100        $famc = ( get_post_meta( $chil, 'famc' ) ? get_post_meta( $chil, 'famc' ) : array() );
     1101        $famc_key = array_search( $fam['fams'], array_column( $famc, 'famc' ) );
     1102        $pedi = ( isset( $famc[$famc_key]['pedi'] ) ? $famc[$famc_key]['pedi'] : '' );
    9421103       
    9431104        if ( $chil ) {
     
    9451106                                                            <input type="hidden" readonly  name="gt[family][spouses][<?php
    9461107            echo  esc_attr( $y ) ;
    947             ?>][chil][]" value="<?php
     1108            ?>][chil][<?php
     1109            echo  esc_attr( $key ) ;
     1110            ?>][id]" value="<?php
    9481111            echo  esc_attr( $chil ) ;
     1112            ?>">
     1113                                                            <input type="hidden" readonly  name="gt[family][spouses][<?php
     1114            echo  esc_attr( $y ) ;
     1115            ?>][chil][<?php
     1116            echo  esc_attr( $key ) ;
     1117            ?>][pedi]" value="<?php
     1118            echo  esc_attr( $pedi ) ;
    9491119            ?>">
    9501120                                                            <?php
  • genealogical-tree/trunk/genealogical-tree.php

    r2900493 r2913641  
    1717 * Plugin URI:        https://wordpress.org/plugins/genealogical-tree
    1818 * Description:       Genealogical Tree is a ultimate solution for creating and displaying family trees, family history on WordPress.
    19  * Version:           2.2.0.7
     19 * Version:           2.2.0.8
    2020 * Author:            ak devs
    2121 * Author URI:        https://github.com/akdevsfr
     
    9393     * Rename this for your plugin and update it as you release new versions.
    9494     */
    95     define( 'GENEALOGICAL_TREE_VERSION', '2.2.0.7' );
     95    define( 'GENEALOGICAL_TREE_VERSION', '2.2.0.8' );
    9696    define( 'GENEALOGICAL_TREE_DIR_URL', plugin_dir_url( __FILE__ ) );
    9797    define( 'GENEALOGICAL_TREE_DIR_PATH', plugin_dir_path( __FILE__ ) );
  • genealogical-tree/trunk/includes/class-genealogical-tree-upgrade.php

    r2829508 r2913641  
    9494            $wife = get_post_meta( $value->ID, 'wife', true );
    9595            $husb = get_post_meta( $value->ID, 'husb', true );
    96             $this->find_or_create_family( $wife, $husb, array( $value->ID ) );
     96
     97            $chills = array( array( 'id'=> $value->ID, 'pedi' => '' ));
     98
     99            $this->find_or_create_family( $wife, $husb, $chills);
    97100        }
    98101
  • genealogical-tree/trunk/includes/class-genealogical-tree.php

    r2891385 r2913641  
    231231        $this->loader->add_action( 'admin_post_process_export_post', $plugin_admin, 'process_export_post' );
    232232        $this->loader->add_action( 'admin_post_process_import_post', $plugin_admin, 'process_import_post' );
     233        // Columns and Quick Edit Fields.
     234        $this->loader->add_filter( 'manage_gt-tree_posts_columns', $plugin_admin, 'tree_family_and_root_columns' );
     235        $this->loader->add_action(
     236            'manage_posts_custom_column',
     237            $plugin_admin,
     238            'tree_populate_family_and_root_columns',
     239            10,
     240            2
     241        );
     242        $this->loader->add_action(
     243            'quick_edit_custom_box',
     244            $plugin_admin,
     245            'tree_quick_edit_fields',
     246            10,
     247            2
     248        );
     249        $this->loader->add_action( 'save_post', $plugin_admin, 'tree_quick_edit_save' );
    233250        $plugin_upgrade = new \Zqe\Genealogical_Tree_Upgrade();
    234251        // ver_upgrade.
  • genealogical-tree/trunk/vendor/autoload.php

    r2891385 r2913641  
    55require_once __DIR__ . '/composer/autoload_real.php';
    66
    7 return ComposerAutoloaderInit7e3ffb6b663a47b34f2137ae95307ad4::getLoader();
     7return ComposerAutoloaderInitc17db3592498abf459462c6906985b7e::getLoader();
  • genealogical-tree/trunk/vendor/composer/autoload_real.php

    r2891385 r2913641  
    33// autoload_real.php @generated by Composer
    44
    5 class ComposerAutoloaderInit7e3ffb6b663a47b34f2137ae95307ad4
     5class ComposerAutoloaderInitc17db3592498abf459462c6906985b7e
    66{
    77    private static $loader;
     
    2525        require __DIR__ . '/platform_check.php';
    2626
    27         spl_autoload_register(array('ComposerAutoloaderInit7e3ffb6b663a47b34f2137ae95307ad4', 'loadClassLoader'), true, true);
     27        spl_autoload_register(array('ComposerAutoloaderInitc17db3592498abf459462c6906985b7e', 'loadClassLoader'), true, true);
    2828        self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
    29         spl_autoload_unregister(array('ComposerAutoloaderInit7e3ffb6b663a47b34f2137ae95307ad4', 'loadClassLoader'));
     29        spl_autoload_unregister(array('ComposerAutoloaderInitc17db3592498abf459462c6906985b7e', 'loadClassLoader'));
    3030
    3131        $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
     
    3333            require __DIR__ . '/autoload_static.php';
    3434
    35             call_user_func(\Composer\Autoload\ComposerStaticInit7e3ffb6b663a47b34f2137ae95307ad4::getInitializer($loader));
     35            call_user_func(\Composer\Autoload\ComposerStaticInitc17db3592498abf459462c6906985b7e::getInitializer($loader));
    3636        } else {
    3737            $map = require __DIR__ . '/autoload_namespaces.php';
  • genealogical-tree/trunk/vendor/composer/autoload_static.php

    r2891385 r2913641  
    55namespace Composer\Autoload;
    66
    7 class ComposerStaticInit7e3ffb6b663a47b34f2137ae95307ad4
     7class ComposerStaticInitc17db3592498abf459462c6906985b7e
    88{
    99    public static $prefixLengthsPsr4 = array (
     
    249249    {
    250250        return \Closure::bind(function () use ($loader) {
    251             $loader->prefixLengthsPsr4 = ComposerStaticInit7e3ffb6b663a47b34f2137ae95307ad4::$prefixLengthsPsr4;
    252             $loader->prefixDirsPsr4 = ComposerStaticInit7e3ffb6b663a47b34f2137ae95307ad4::$prefixDirsPsr4;
    253             $loader->classMap = ComposerStaticInit7e3ffb6b663a47b34f2137ae95307ad4::$classMap;
     251            $loader->prefixLengthsPsr4 = ComposerStaticInitc17db3592498abf459462c6906985b7e::$prefixLengthsPsr4;
     252            $loader->prefixDirsPsr4 = ComposerStaticInitc17db3592498abf459462c6906985b7e::$prefixDirsPsr4;
     253            $loader->classMap = ComposerStaticInitc17db3592498abf459462c6906985b7e::$classMap;
    254254
    255255        }, null, ClassLoader::class);
  • genealogical-tree/trunk/vendor/composer/installed.php

    r2891385 r2913641  
    66        'install_path' => __DIR__ . '/../../',
    77        'aliases' => array(),
    8         'reference' => 'a9f719ad1c8d4465233c6dd6ddcfbf64aa17da1d',
     8        'reference' => '136a99b2645936db29ee04a69e442ae322b9a798',
    99        'name' => 'akdevsfr/genealogical-tree',
    1010        'dev' => false,
     
    1717            'install_path' => __DIR__ . '/../../',
    1818            'aliases' => array(),
    19             'reference' => 'a9f719ad1c8d4465233c6dd6ddcfbf64aa17da1d',
     19            'reference' => '136a99b2645936db29ee04a69e442ae322b9a798',
    2020            'dev_requirement' => false,
    2121        ),
Note: See TracChangeset for help on using the changeset viewer.