ID; /* if we have no field name passed go no further */ if( empty( $field ) ) return false; /* build the meta key to return the value for */ $key = $prefix . $field; /* gete the post meta value for this field name of meta key */ $field = get_post_meta( $post_id, $key, true ); return apply_filters( 'pcapredict_field_value', $field ); } /** * function pcapredict_get_setting() * * gets a named plugin settings returning its value * @param mixed key name to retrieve - this is the key of the stored option * @return mixed the value of the key */ function pcapredict_get_setting( $name = '' ) { /* if no name is passed */ if( empty( $name ) ) { return false; } /* get the option */ $setting = get_option( 'pcapredict_' . $name ); /* check we have a value returned */ if( empty( $setting ) ) { return false; } return apply_filters( 'pcapredict_get_setting', $setting ); } /** * pcapredict_on_activation() * On plugin activation makes current user a wpbasis user and * sets an option to redirect the user to another page. */ function pcapredict_on_activation() { /* set option to initialise the redirect */ add_option( 'pcapredict_activation_redirect', true ); } register_activation_hook( __FILE__, 'pcapredict_on_activation' ); /** * pcapredict_activation_redirect() * Redirects user to the settings page for wp basis on plugin * activation. */ function pcapredict_activation_redirect() { /* check whether we should redirect the user or not based on the option set on activation */ if( true == get_option( 'pcapredict_activation_redirect' ) ) { /* delete the redirect option */ delete_option( 'pcapredict_activation_redirect' ); /* redirect the user to the wp basis settings page */ wp_redirect( admin_url( 'admin.php?page=pcapredict_settings' ) ); exit; } } add_action( 'admin_init', 'pcapredict_activation_redirect' ); /** * pcapredict_hook_javascript() * * Adds the PCA tag to the head of every page */ function pcapredict_hook_javascript() { $accCode = pcapredict_get_setting( 'accountcode' ); if ( $accCode ) { ?>