Plugin Directory

Changeset 2296827


Ignore:
Timestamp:
05/02/2020 08:02:39 PM (6 years ago)
Author:
kylerboudreau
Message:

Made several changes for this new version including a Contact Form 7 fix and other minor fixes.

Location:
follow-hook/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • follow-hook/trunk/cron_job_settings.php

    r2141463 r2296827  
    66    </div>
    77
    8     <div class="dashboard-line"></div>
     8
    99
    1010    <div class="dashboard-pad">
  • follow-hook/trunk/follow-hook.php

    r2169546 r2296827  
    44Plugin URI: https://followhook.com/
    55Description: A custom CRM plugin developed by Kyler Boudreau and Ian Lincicome.
    6 Version: 1.0.4
     6Version: 1.1.0
    77Author: Kyler Boudreau and Ian Lincicome of Follow Hook
    88Author URI: https://followhook.com
     
    5151        'has_archive' => true,
    5252        'rewrite' => array('slug' => 'people'),
    53         'supports' => array( 'title' )
     53        //you must enter all the fields below that you want to show up as options in wp-admin/Follow Hook/forms/associate fields:
     54        'supports' => array( 'title','_firstname','_lastname', '_email','_pph','_wph','_contact_method','_addy1', 'addy2','_city','_state','_zip','_country','','')
    5455        )
    5556    );
     
    707708    update_post_meta($post_id, '_lastname', sanitize_text_field($_POST['_lastname']));
    708709    update_post_meta($post_id, '_status', $GDPR_opt);
    709     update_post_meta($post_id, '_email', sanitize_email($_POST['_email']));
     710    update_post_meta($post_id, '_email', $_POST['_email']);
    710711    update_post_meta($post_id, '_pph', sanitize_text_field($_POST['_pph']));
    711712    update_post_meta($post_id, '_wph', sanitize_text_field($_POST['_wph']));
     
    821822
    822823
    823 
     824//includes the pods taxonomy and PB_campaigns taxonomy:
    824825include 'pods.php';
    825 
    826 
    827826
    828827add_action('admin_head', 'Follow_Hook_remove_parents_and_slugs');
     
    880879
    881880//function to testpg.php inclusion:
    882 //function testpg(){include 'testpg.php';}//comment this and 3 lines up out when not in test mode!
     881function testpg(){include 'testpg.php';}//comment this and 3 lines up out when not in test mode!
    883882//function testpg2(){include 'testpg2.php';}//comment this and 3 lines up out when not in test mode!
    884883
     
    17141713// Search posts containing this look-for text.
    17151714$posts_f = $wpdb->get_results($sql);
     1715if(!is_array($posts_f)){
     1716    $posts_f = array();
     1717}//
    17161718$posts_found = count($posts_f);
    17171719//echo "TESTING......posts: $posts_found<br />";
     
    18341836
    18351837//added code to make the email field for People CPT unique:
    1836 add_filter( 'add_post_metadata', 'unique_email_for_people', 10, 4 );
    1837 add_filter( 'update_post_metadata', 'unique_email_for_people', 10, 4 );
     1838//add_filter( 'add_post_metadata', 'unique_email_for_people', 10, 4 );
     1839//add_filter( 'update_post_metadata', 'unique_email_for_people', 10, 4 );
    18381840
    18391841function unique_email_for_people($null, $pid, $key, $value) {
    1840     //Follow_Hook_log_debug("unique_email_for_people function activated with:\nnull = $null\npid = $pid\nkey = $key\nvalue = $value\n\n", "debug_email.log");
     1842    Follow_Hook_log_debug("unique_email_for_people function activated with:\nnull = $null\npid = $pid\nkey = $key\nvalue = $value\n\n", "debug_email.log");
    18411843    //get the custom post type from the post id of $pid:
    18421844    $post_type = get_post_type($pid);
     
    18631865        return FALSE;
    18641866        }else{
     1867            Follow_Hook_log_debug("returning null value because this person already has that email value saved...\n\n", "debug_email.log");
    18651868            return $null;
    18661869        }
     
    18681871}//end unique_email_for_people function
    18691872
     1873
     1874
     1875
     1876
     1877// add the filter for next function below:
     1878add_filter('update_post_metadata', 'FH_check_people_email', 10, 4);
     1879add_filter( 'add_post_metadata', 'FH_check_people_email', 10, 4 );
     1880// define the update_post_metadata callback
     1881function FH_check_people_email($array, $post_id, $k, $val) {
     1882
     1883$post_type = get_post_type($post_id);
     1884if($k !== '_email' || $post_type !== 'people'){
     1885    return $null;
     1886    }else{
     1887    // make filter magic happen here...
     1888    //Follow_Hook_log_debug("array value: $array\n","eml.log");
     1889    Follow_Hook_log_debug("Post ID: $post_id\n","eml.log");
     1890    Follow_Hook_log_debug("K: $k\n","eml.log");
     1891    Follow_Hook_log_debug("Val: $val\n","eml.log");
     1892    //Follow_Hook_log_debug("next value: $a\n","eml.log");
     1893    //return $array;
     1894    //see if email exists:
     1895  global $wpdb;
     1896  $exists = $wpdb->get_col($wpdb->prepare(
     1897    "SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key = %s AND meta_value = %s",
     1898    $k, $val
     1899  ));
     1900  //If email exists don't save it and throw error:
     1901    if(!empty($exists)){
     1902       
     1903        $foundid = $exists[0];
     1904        Follow_Hook_log_debug("Found email for user with id: $foundid\n\n","eml.log");
     1905        //only throw err if $foundid and $post_id do not match!
     1906        if($foundid != $post_id){
     1907            //echo "<p style='color:red'>ERROR! That email has already been used by another person, use another!</p>";
     1908            //add_action( 'admin_notices', 'FH_people_admin_notice',10, 2 );
     1909        fh_error('email_exists','Oops! The email you have entered belongs to another person, please use another email address.');
     1910        Follow_Hook_log_debug("Sent error.... This user id: $post_id Other user using email id: $foundid\n\n","eml.log");           
     1911        //throw wp-admin error:
     1912       
     1913        $_SESSION['Follow_Hook_my_admin_notices'] .=  '<div class="notice notice-error is-dismissible"><p>Opps! Sorry, a person with email '.$val.' already exists, please use a different email address to continue.</p></div>';
     1914        return false;
     1915        }
     1916    }
     1917    }
     1918}
     1919
     1920
     1921//Ian added error handling function for use with save_touchpoint_data function below it:
     1922add_action('admin_notices', 'handle_eml_errors');
     1923/**
     1924 * Writes an error message to the screen if error is thrown in save_touchpoint_data function
     1925 *
     1926 */
     1927function handle_eml_errors() {
     1928  //If there are no errors, then exit the function
     1929  if(!( $errors = get_transient('settings_errors'))) {
     1930    return;
     1931  }
     1932  //Otherwise, build the list of errors that exist in the settings errors
     1933  $message = '<div id="acme-message" class="error below-h2"><p><ul>';
     1934  foreach($errors as $error) {
     1935    $message .= '<li>' . $error['message'] . '</li>';
     1936  }
     1937  $message .= '</ul></p></div><!-- #error -->';
     1938  // Write them out to the screen
     1939  echo $message;
     1940  // Clear and the transient and unhook any other notices so we don't see duplicate messages
     1941  delete_transient('settings_errors');
     1942  remove_action('admin_notices', 'handle_eml_errors');
     1943}
     1944
     1945
     1946function fh_error($slug,$err){
     1947    add_settings_error(
     1948        $slug,
     1949        $slug,
     1950        $err,
     1951        'error'
     1952    );
     1953    set_transient('settings_errors', get_settings_errors(), 30);
     1954}//end fh_error function by Ian L. of Jafty.com
     1955
     1956
     1957
     1958
     1959
     1960
     1961function FH_people_admin_notice($a) {
     1962    Follow_Hook_log_debug("a:$a\n","eml.log");
     1963    ?>
     1964    <div class="notice error my-acf-notice is-dismissible" >
     1965        <p><?php _e( 'That Email already exists, please try another!', 'follow-hook' ); ?></p>
     1966    </div>
     1967
     1968
     1969    <?php
     1970}
     1971
     1972//add_action( 'admin_notices', 'FH_people_admin_notice' );
     1973             
     1974
     1975
     1976
     1977
     1978
     1979
     1980
     1981
    18701982function Follow_Hook_my_admin_notices(){
    18711983  if(!empty($_SESSION['Follow_Hook_my_admin_notices'])) print  $_SESSION['Follow_Hook_my_admin_notices'];
    18721984  unset ($_SESSION['Follow_Hook_my_admin_notices']);
    18731985}
    1874 add_action( 'admin_notices', 'Follow_Hook_my_admin_notices' );
     1986//add_action('admin_notices', 'Follow_Hook_my_admin_notices', 4);
    18751987
    18761988
  • follow-hook/trunk/forms_admin_pg.php

    r2167803 r2296827  
    176176    }
    177177   
     178//set up Follow Hook people fields for dropdown of field names:
     179$cult_opts = "";
     180$justkeys = array();
     181global $wpdb;
    178182$table_name3 = $wpdb->prefix . 'custom_fields';
    179183$fields = $wpdb->get_results("SELECT DISTINCT name, type FROM $table_name3", ARRAY_A );
    180    
    181     //set up cultivate fields as options for use in the cult_fld select field below:
    182     //find the people post with the most saved fields, and use that to get field names from:
    183     $mostflds = 0;
    184     $posts_ids = get_posts('post_type=people&posts_per_page=-1&fields=ids');
    185     foreach($posts_ids as $posid){
    186         $custom_fields = get_post_meta($posid);
    187         $c = count($custom_fields);
    188         if($c>$mostflds){//store the id of the post with the most fields in $high_id variable:
    189             $mostflds = $c;
    190             $high_id = $posid;
    191         }//end if id has the most fields
    192     }//end foreach post id
    193 $custom_fields = get_post_meta($high_id);
    194     unset($custom_fields['_edit_lock']);
    195     unset($custom_fields['_edit_last']);
    196     $custom_fields['post_title']='';
    197     //array_unshift($custom_fields , );
    198     $first_option = array('none' => 'none');
    199     $custom_fields = $first_option + $custom_fields;
    200     $cult_opts="";
    201 
    202     foreach($custom_fields as $key => $value) {
    203         //see if key has _tp_note_ in it and disgard if so:
    204         $ps = strpos($key,'tp_note_');
    205         //echo "pos of $key: ".$ps."<br />";
    206         if($ps !== 1){
    207         $cult_opts.="<option";
    208         if($key==$cf)$cult_opts.=" selected";
    209         $cult_opts.= ">$key</option>";
    210         $justkeys[] = $key;
    211         }
    212     }//end foreach custom_fields as ...
    213    
    214     //added code here to add fields from custom_fields table to the custom fields dropdown:
    215     //now go over the fields array from custom_fields table and add those options if the aren't in justkeys array:
     184$cult_opts .= "<option>Pick one</option>";
     185
    216186foreach($fields as $ke => $val){
    217187    $nm = $val['name'];
     
    222192        if($nm==$cf)$cult_opts.=" selected";
    223193        $cult_opts.= ">$nm</option>";
    224     }
    225 }//end foreach field   
     194        $justkeys[] = $nm;
     195    }
     196}//end foreach custom field
     197
     198$post_type_features = get_all_post_type_supports( 'people' );
     199//print_r( $post_type_features );
     200foreach($post_type_features as $fld=>$v){//for ea. of the people fields:
     201    $i++;
     202    //echo ") $fld<br />";
     203    if(!in_array($fld,$justkeys)){
     204        $cult_opts .= "<option";
     205        if($fld==$cf)$cult_opts.=" selected";
     206        $cult_opts.= ">$fld</option>";
     207        $justkeys[] = $fld;
     208    }
     209}//end for ea. of the people fields..   
    226210   
    227211    echo "<tr><td>$n</td><td>$t</td><td><select name='cult_fld$n'><option>Pick Follow Hook Field</option>$cult_opts</select></td></tr>";
  • follow-hook/trunk/pods.php

    r2167808 r2296827  
    3838    //'description' => 'You may group contacts by pods'
    3939  ));
     40 
     41 
     42
     43 
     44 
     45 
    4046}//end create_pods_hierarchical_taxonomy function
    4147
Note: See TracChangeset for help on using the changeset viewer.