Skip to content

Instantly share code, notes, and snippets.

View ajgagnon's full-sized avatar
💻
typing some things

Andre Gagnon ajgagnon

💻
typing some things
View GitHub Profile
@ajgagnon
ajgagnon / projecthuddle_add_stylesheet.php
Last active August 2, 2016 14:13
How to add a custom stylesheet to your ProjectHuddle project page.
<?php
/**
* Add your custom stylesheet
* Be sure to change 'my' to your own prefix to prevent conflicts
*/
function my_projecthuddle_styles() {
wp_enqueue_style( 'my_ph_style', get_stylesheet_directory_uri() . '/path/to/your/stylesheet.css', 'project-huddle', '1.0' );
}
add_action( 'wp_enqueue_scripts', 'my_projecthuddle_styles' );
@ajgagnon
ajgagnon / projecthuddle_event_listen.js
Last active October 9, 2015 22:08
Listen for comment items being saved in ProjectHuddle
(function($){
$(document ).ready(function(){
Huddle.Event.on( 'commentSavedSuccess', function( $model ){
// run when comment was saved
// this is the model object that was saved
console.log($model);
});
});
})(jQuery);
@ajgagnon
ajgagnon / projecthuddle_add_script.php
Last active August 2, 2016 14:13
How to add a custom script to your ProjectHuddle project page.
<?php
/**
* Add your custom script
* Be sure to change 'my' to your own prefix to prevent conflicts
*/
function my_projecthuddle_scripts() {
// add a new script using wp_enqueue_script
wp_enqueue_script( 'my_ph_script', get_stylesheet_directory_uri() . '/path/to/your/script.js', array(
'jquery',
'backbone',
@ajgagnon
ajgagnon / projecthuddle_add_inline_css.php
Last active July 22, 2016 17:57
Quickly Add Inline CSS to a Project PAge
<?php
/*
* Quickly add inline css styles to a project
* Replace .postid-3996 with your own project id
*/
function ph_add_inline_styles() {
$custom_css = "
.postid-3996 .ph-project-image-inner {
height: 100%;
}
@ajgagnon
ajgagnon / ph-user-submits-comment.js
Last active June 26, 2019 17:04
Show a dialog after a user submits a comment.
(function($){
function phSetCookie(cname, cvalue, exdays) {
var d = new Date();
d.setTime(d.getTime() + (exdays*24*60*60*1000));
var expires = "expires="+ d.toUTCString();
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
}
function phGetCookie(cname) {
var name = cname + "=";
@ajgagnon
ajgagnon / projecthuddle_change_default_project_options.php
Created December 17, 2016 22:32
ProjectHuddle Change Default Project Options
<?php
function wp123_ph_change_default_project_options($options) {
foreach ($options as $key => $val) {
if ($val['project_unapproval'] === $id) {
$unapproval = $key;
}
}
$options[$unapproval]['default'] = 'off';
return $options;
}
@ajgagnon
ajgagnon / change-subscribed-user-email-role.php
Last active January 4, 2017 21:44
Change subscribed user email based on role
<?php
/**
* Change the collaborate subject for project clients
*/
function wp395_ph_change_collaborate_subject( $subject, $email, $user, $post_id ) {
// if user is a project client
if ( user_can( $user, 'project_client' ) ) {
$subject = 'Your Design Project is in progress.';
}
@ajgagnon
ajgagnon / ph-user-approves-image.php
Last active February 20, 2020 17:38
Show a request a review popup after approval.
<?php
add_action('wp_enqueue_scripts', function () {
wp_add_inline_script('project-huddle', "
/**
* Hook into Approve Button View initialize method
*/
ph.api.hooks.addAction('ph.api.views.ApproveButton.initialize', 'custom-popup', function (view) {
view.messageAfterApproval();
});
(function($){
$(document).ready(function() {
/**
* Hook into ImageView initialize method
*/
wp.hooks.addAction('Huddle.CommentView.initialize', function (view) {
view.messageAfterFirstComment();
});
@ajgagnon
ajgagnon / ph-add-settings-to-extensions-page.php
Last active April 6, 2017 16:09
ProjectHuddle: Add Settings To Extensions Page
<?php
// filter plugin settings
add_filter( 'ph_settings_extensions', 'my_extension_plugin_settings' );
// add our settings
function my_extension_plugin_settings($settings) {
// add fields
// divider with title
$settings['fields'][] = array(