/** * Retrieve the name of the highest priority template file that exists. * * Searches in the STYLESHEETPATH before TEMPLATEPATH so that themes which * inherit from a parent theme can just overload one file. Falls back to the * built-in template. * * @since 1.1.0 * @see locate_template() * * @param string|array $template_names Template file(s) to search for, in order. * @param bool $load If true the template file will be loaded if it is found. * @param bool $require_once Whether to require_once or require. Default true. Has no effect if $load is false. * @return string The template path if one is located. */ function gfiframe_locate_template($template_names, $load = false, $require_once = true) { $template = ''; foreach ((array) $template_names as $template_name) { if (!$template_name) { continue; } if (file_exists(get_stylesheet_directory() . '/' . $template_name)) { $template = get_stylesheet_directory() . '/' . $template_name; break; } elseif (file_exists(get_template_directory() . '/' . $template_name)) { $template = get_template_directory() . '/' . $template_name; break; } elseif (file_exists(gfiframe()->get_path('templates/' . $template_name))) { $template = gfiframe()->get_path('templates/' . $template_name); break; } } if ($load && !empty($template)) { load_template($template, $require_once); } return $template; }
/** * Retrieve the main GravityFormsIframe_Addon instance. * * @since 1.0.0 * * @return GravityFormsIframe */ public static function instance() { return gfiframe(); }
$file .= '.php'; if (file_exists($file)) { require_once $file; } } spl_autoload_register('gfiframe_autoloader'); /** * Retrieve the main plugin instance. * * @since 2.0.0 * * @return GravityFormsIframe_Plugin */ function gfiframe() { static $instance; if (null === $instance) { $instance = new GravityFormsIframe_Plugin(); } return $instance; } $gfiframe = gfiframe()->set_basename(plugin_basename(__FILE__))->set_directory(plugin_dir_path(__FILE__))->set_file(__FILE__)->set_slug('gravity-forms-iframe')->set_url(plugin_dir_url(__FILE__))->register_hooks(new GravityFormsIframe_Provider_Setup())->register_hooks(new GravityFormsIframe_Provider_I18n()); /** * Include helper functions and backward compatibility files. */ include $gfiframe->get_path('includes/deprecated.php'); include $gfiframe->get_path('includes/functions.php'); /** * Load the plugin. */ add_action('plugins_loaded', array($gfiframe, 'load_plugin'));