Skip to content

Instantly share code, notes, and snippets.

@pjhoberman
Created December 12, 2017 23:47
Show Gist options
  • Save pjhoberman/1e12c8df5b891da97e8386108803cc7a to your computer and use it in GitHub Desktop.
Save pjhoberman/1e12c8df5b891da97e8386108803cc7a to your computer and use it in GitHub Desktop.
diff --git a/wp-content/scripts/functions.php b/wp-content/scripts/functions.php
index 8bba0c8..da713b2 100755
--- a/wp-content/scripts/functions.php
+++ b/wp-content/scripts/functions.php
@@ -7,7 +7,7 @@ require_once($_SERVER['DOCUMENT_ROOT'] . "/wp-content/scripts/nightout.php");
function set_nightout_globals() {
global $api_url, $api_oauth_string, $api_org_ids, $api_all_events_url;
$api_url = "https://nightout.com/api/events";
- $api_oauth_string = "?oauth_token=3d4zpwlv3g3wmt30x7rqvcosyl57btu";
+ $api_oauth_string = "?oauth_token=1inqpsbritaqkoue50ln8amfozqdlaz";
$api_org_ids = "&organization_ids=357,358,576,625,781,779,851,849,881,617,780,3492,592,246,639,906,907,942,917,3486,3498";
$api_all_events_url = $api_url . $api_oauth_string . $api_org_ids;
<?php
/*************************/
/* PJ's added functions */
/************************/
require_once($_SERVER['DOCUMENT_ROOT'] . "/wp-content/scripts/nightout.php");
function set_nightout_globals() {
global $api_url, $api_oauth_string, $api_org_ids, $api_all_events_url;
$api_url = "https://nightout.com/api/events";
$api_oauth_string = "?oauth_token=1inqpsbritaqkoue50ln8amfozqdlaz";
$api_org_ids = "&organization_ids=357,358,576,625,781,779,851,849,881,617,780,3492,592,246,639,906,907,942,917,3486,3498";
$api_all_events_url = $api_url . $api_oauth_string . $api_org_ids;
}
add_action( 'init', 'set_nightout_globals');
/* Event Details redirect */
// Source: http://code.tutsplus.com/articles/custom-page-template-page-based-on-url-rewrite--wp-30564
function event_details_rewrite_rule() {
add_rewrite_rule( 'event/([^/]+)/?', 'index.php?event_slug=$matches[1]', 'top' );
}
add_action( 'init', 'event_details_rewrite_rule' );
function prefix_register_query_var( $vars ) {
$vars[] = 'event_slug';
return $vars;
}
add_filter( 'query_vars', 'prefix_register_query_var' );
function prefix_url_rewrite_templates() {
if ( get_query_var( 'event_slug' ) ) {
add_filter( 'template_include', function() {
return get_stylesheet_directory() . '/page-templates/event-details.php';
});
// todo - might make sense to move this to a different function...
add_action('wp_head', function(){
global $event_slug, $this_event;
$this_event = getThisEvent($event_slug);
$event_description = $this_event -> description;
if( $event_description === "" ) {
$event_description = ": Imbibe is craft events. We specialize in craft beer and spirit events and ticketing.";
}
$event_description = $this_event -> title . " - " . $event_description;
// make it a summary - cut it at first line break (p, br, div)
$pattern = '/(<\/p.*|<br.*|<\/div.*)/is';
$event_description = preg_replace($pattern, "", $event_description);
$event_description = htmlspecialchars(strip_tags($event_description));
$og_title = $this_event -> title . " | Imbibe Events";
?>
<!-- for Google -->
<meta name="description" content="<?= $event_description ?>" />
<meta name="keywords" content="<?= $this_event -> title ?>, craft, events, craft beer, spirits, ticketing, tickets, festivals" />
<meta name="author" content="Imbibe" />
<meta name="copyright" content="<?= date("Y"); ?>" />
<meta name="application-name" content="Imbibe Events" />
<!-- for Facebook -->
<meta property="og:title" content="<?= $og_title ?>" />
<meta property="og:image" content="<?= $this_event -> poster_url -> large ?>" />
<meta property="og:url" content="<?= get_site_url() . $_SERVER['REQUEST_URI']; ?>" />
<meta property="og:description" content="<?= $event_description ?>" />
<!-- for Twitter -->
<meta name="twitter:card" content="summary" />
<meta name="twitter:title" content="<?= $og_title ?>" />
<meta name="twitter:description" content="<?= $event_description ?>" />
<meta name="twitter:image" content="<?= $this_event -> poster_url -> large ?>" />
<?
});
//Remover YOAST settings on these pages
add_filter( 'wpseo_canonical', 'wpseo_canonical_exclude' );
function wpseo_canonical_exclude( $canonical ) {
$canonical = false;
return $canonical;
}
add_filter( 'wpseo_description', 'wpseo_description_exclude' );
function wpseo_description_exclude( $description ) {
$description = false;
return $description;
}
// end of making sense
}
}
add_action( 'template_redirect', 'prefix_url_rewrite_templates' );
/* end Event Details redirect */
add_filter( 'wp_title', 'og_title', 20 );
function og_title($title) {
global $event_slug, $this_event;
if ($event_slug !== null && $event_slug !== "") {
$this_event = getThisEvent($event_slug);
$title = $this_event -> title . " | $title";
}
return $title;
}
pjhoberman@pjs-mbp:~/Projects/twoparts[fire|SP]$ git st
On branch fire
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: wp-content/scripts/functions.php
no changes added to commit (use "git add" and/or "git commit -a")
pjhoberman@pjs-mbp:~/Projects/twoparts[fire|!SP]$ git diff
diff --git a/wp-content/scripts/functions.php b/wp-content/scripts/functions.php
index 8bba0c8..da713b2 100755
--- a/wp-content/scripts/functions.php
+++ b/wp-content/scripts/functions.php
@@ -7,7 +7,7 @@ require_once($_SERVER['DOCUMENT_ROOT'] . "/wp-content/scripts/nightout.php");
function set_nightout_globals() {
global $api_url, $api_oauth_string, $api_org_ids, $api_all_events_url;
$api_url = "https://nightout.com/api/events";
- $api_oauth_string = "?oauth_token=3d4zpwlv3g3wmt30x7rqvcosyl57btu";
+ $api_oauth_string = "?oauth_token=1inqpsbritaqkoue50ln8amfozqdlaz";
$api_org_ids = "&organization_ids=357,358,576,625,781,779,851,849,881,617,780,3492,592,246,639,906,907,942,917,3486,3498";
$api_all_events_url = $api_url . $api_oauth_string . $api_org_ids;
pjhoberman@pjs-mbp:~/Projects/twoparts[fire|!SP]$ git commit -am "oauth"
[fire 29aa39b] oauth
1 file changed, 1 insertion(+), 1 deletion(-)
pjhoberman@pjs-mbp:~/Projects/twoparts[fire|SP]$ git push staging fire
Counting objects: 5, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (5/5), 444 bytes | 0 bytes/s, done.
Total 5 (delta 4), reused 0 (delta 0)
remote: git.wpengine.com: validating
remote: - info: detected push to staging application ...
remote: - info: validating files in 29aa39b ...
remote: - info: found application servers ...
remote: - info: checking for syntax errors ...
remote: - info: checking wp-content/scripts/functions.php ...
remote: PHP Parse error: syntax error, unexpected end of file in - on line 124
remote: - warning: syntax Error Found in wp-content/scripts/functions.php ...
remote: - info: checking wp-content/scripts/nightout.php ...
remote: - failed: we detected a PHP syntax failure.
To [email protected]:staging/imbibe.git
! [remote rejected] fire -> fire (pre-receive hook declined)
error: failed to push some refs to '[email protected]:staging/imbibe.git'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment