commented unused code and css in functions.php

This commit is contained in:
jorge 2022-07-05 07:25:19 +02:00
parent be1eacaaad
commit 667b66dffc
1 changed files with 91 additions and 91 deletions

View File

@ -63,85 +63,85 @@ add_filter('admin_footer_text', 'remove_footer_admin');
// THIS GIVES US SOME OPTIONS FOR STYLING THE ADMIN AREA
function custom_controls() {
echo '<style type="text/css">
label.lateral{width: 100px;}
input.lateral{width: 150px; border-color: #ddd;}
.petit {width: 20px!important;}
label.dd{float:left; width:250px;}
input.dd{width:450px;}
</style>';
// echo '<style type="text/css">
// label.lateral{width: 100px;}
// input.lateral{width: 150px; border-color: #ddd;}
// .petit {width: 20px!important;}
// label.dd{float:left; width:250px;}
// input.dd{width:450px;}
// </style>';
}
add_action('admin_head', 'custom_controls');
/* create calendar event when saving post with dates */
function create_event( $post_id ) {
// If this is just a revision, don't send the email.
if ( wp_is_post_revision( $post_id ) )
return;
$myPost = get_post($post_id);
if (has_category(array('news', 'activitats-dels-residents'), $post_id) &&
!$update &&
$myPost->post_modified_gmt == $myPost->post_date_gmt) {
//The URL that we want to send a PUT request to.
$uid = get_the_guid( $post_id );
$url = 'https://cloud.hangar.org/remote.php/dav/calendars/hangar/hangar_activitats/neu.ics';
$headers = array('Content-Type: text/calendar', 'charset=utf-8');
$userpwd = 'hangar:AV63xlklCuOJgYTnHz5smX4chiAaDpJo';
$description = get_the_content( $post_id );
$summary = get_the_title( $post_id );
$tstart = gmdate("Ymd\THis\Z", strtotime("-2 days"));
$tend = gmdate("Ymd\THis\Z", strtotime("-2 days"));
$tstamp = gmdate("Ymd\THis\Z");
// vcalendar
$body = 'BEGIN:VCALENDAR
VERSION:2.0
BEGIN:VEVENT
DTSTAMP:$tstamp
DTSTART:$tstart
DTEND:$tend
UID:$uid
DESCRIPTION:$description
LOCATION:Hangar
SUMMARY:$summary
END:VEVENT
END:VCALENDAR';
//Initiate cURL
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, $userpwd);
//curl_setopt($ch, CURLOPT_PUT, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
//Execute the request.
$response = curl_exec($ch);
curl_close($ch);
// send confirmation mail
$post_title = $summary;
$post_excerpt = $description;
$post_url = get_permalink( $post_id );
$subject = 'A new EVENT post has been saved';
$message = "A new post has been created on your website:\n\n";
$message .= $post_title . ": " . $post_url . "\n\n";
$message .= $post_excerpt . "\n\n";
$message .= $uid . "\n\n";
$message .= print_r($response);
// Send email to admin.
wp_mail( 'gerald@hangar.org', $subject, $message );
}
}
add_action( 'save_post', 'create_event', 10, 3 );
// function create_event( $post_id ) {
//
// // If this is just a revision, don't send the email.
// if ( wp_is_post_revision( $post_id ) )
// return;
//
// $myPost = get_post($post_id);
// if (has_category(array('news', 'activitats-dels-residents'), $post_id) &&
// !$update &&
// $myPost->post_modified_gmt == $myPost->post_date_gmt) {
//
// //The URL that we want to send a PUT request to.
// $uid = get_the_guid( $post_id );
// $url = 'https://cloud.hangar.org/remote.php/dav/calendars/hangar/hangar_activitats/neu.ics';
// $headers = array('Content-Type: text/calendar', 'charset=utf-8');
// $userpwd = 'hangar:AV63xlklCuOJgYTnHz5smX4chiAaDpJo';
// $description = get_the_content( $post_id );
// $summary = get_the_title( $post_id );
// $tstart = gmdate("Ymd\THis\Z", strtotime("-2 days"));
// $tend = gmdate("Ymd\THis\Z", strtotime("-2 days"));
// $tstamp = gmdate("Ymd\THis\Z");
//
// // vcalendar
// $body = 'BEGIN:VCALENDAR
// VERSION:2.0
// BEGIN:VEVENT
// DTSTAMP:$tstamp
// DTSTART:$tstart
// DTEND:$tend
// UID:$uid
// DESCRIPTION:$description
// LOCATION:Hangar
// SUMMARY:$summary
// END:VEVENT
// END:VCALENDAR';
//
// //Initiate cURL
// $ch = curl_init($url);
// curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
// curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
// curl_setopt($ch, CURLOPT_USERPWD, $userpwd);
// //curl_setopt($ch, CURLOPT_PUT, true);
// curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
// curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
//
// //Execute the request.
// $response = curl_exec($ch);
// curl_close($ch);
//
// // send confirmation mail
// $post_title = $summary;
// $post_excerpt = $description;
// $post_url = get_permalink( $post_id );
// $subject = 'A new EVENT post has been saved';
//
// $message = "A new post has been created on your website:\n\n";
// $message .= $post_title . ": " . $post_url . "\n\n";
// $message .= $post_excerpt . "\n\n";
// $message .= $uid . "\n\n";
// $message .= print_r($response);
//
// // Send email to admin.
// wp_mail( 'gerald@hangar.org', $subject, $message );
// }
// }
// add_action( 'save_post', 'create_event', 10, 3 );
//per imprimir el content sense que ens tregui l'html
function get_the_content_with_formatting ($more_link_text = '(...)', $stripteaser = 0, $more_file = '') {
@ -152,23 +152,23 @@ function get_the_content_with_formatting ($more_link_text = '(...)', $striptease
return $content;
}
//per imprimir l'excerpt indicant un nombre de caràcters màxim
function the_excerpt_max_charlength($charlength) {
$excerpt = get_the_excerpt();
$charlength++;
if(strlen($excerpt)>$charlength) {
$subex = substr($excerpt,0,$charlength-5);
$exwords = explode(" ",$subex);
$excut = -(strlen($exwords[count($exwords)-1]));
if($excut<0) {
echo substr($subex,0,$excut);
} else {
echo $subex;
}
echo "[...]";
} else {
echo $excerpt;
}
}
// function the_excerpt_max_charlength($charlength) {
// $excerpt = get_the_excerpt();
// $charlength++;
// if(strlen($excerpt)>$charlength) {
// $subex = substr($excerpt,0,$charlength-5);
// $exwords = explode(" ",$subex);
// $excut = -(strlen($exwords[count($exwords)-1]));
// if($excut<0) {
// echo substr($subex,0,$excut);
// } else {
// echo $subex;
// }
// echo "[...]";
// } else {
// echo $excerpt;
// }
// }
//afegir estils a l'editor