/** * Get file fullpath to include * * param @string $basename * * return @string * */ function _include_file_by_field_type($basename) { $file = wpcf_get_fullpath_by_field_type($basename); if (file_exists($file)) { include_once $file; } return $file; }
/** * Loads type configuration file and calls action. * * @param type $type * @param type $action * @param type $args */ function wpcf_fields_type_action($type, $func = '', $args = array()) { static $actions = array(); $func_in = $func; $md5_args = md5(serialize($args)); if (!isset($actions[$type . '-' . $func_in . '-' . $md5_args])) { $fields_registered = wpcf_admin_fields_get_available_types(); if (isset($fields_registered[$type]) && isset($fields_registered[$type]['path'])) { $file = $fields_registered[$type]['path']; } else { if (defined('WPCF_INC_ABSPATH')) { $file = WPCF_INC_ABSPATH . '/fields/' . $type . '.php'; } else { $file = ''; } } $file_embedded = wpcf_get_fullpath_by_field_type($type); if (file_exists($file) || file_exists($file_embedded)) { if (file_exists($file)) { require_once $file; } if (file_exists($file_embedded)) { require_once $file_embedded; } if (empty($func)) { $func = 'wpcf_fields_' . $type; } else { $func = 'wpcf_fields_' . $type . '_' . $func; } if (function_exists($func)) { $actions[$type . '-' . $func_in . '-' . $md5_args] = call_user_func($func, $args); } else { $actions[$type . '-' . $func_in . '-' . $md5_args] = false; } } else { $actions[$type . '-' . $func_in . '-' . $md5_args] = false; } } return $actions[$type . '-' . $func_in . '-' . $md5_args]; }