Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 05-20-2016, 02:23 PM
GHRake GHRake is offline
 
Join Date: Sep 2015
Location: USA
Posts: 46
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Social Media Plugin Code Review

Hello friends, I've been learning PHP and creating my first plugin the past few days. I'm using Nexia's OpenGraph Protocol Inserts as a basis for my project, so many thanks and credits for this great modification. I've shot him an email asking permission to perhaps update/release this project and am waiting to hear back.

The plugin accomplishes this so far:
  • Adds Open Graph and Twitter Card meta tags to pages for better sharing
  • Includes code linking Facebook Domain and app insights to your page
  • vbAdvanced Support (the main reason I started modifying this)
  • Picks an image from the content with priority being video, then hot linked image, then attached image.
  • Grabs thumbnail from youtube video and drives traffic from your social share to your page instead of youtube
  • Defaults to a vboptions defined image if no image is found, no more social shares without images or badly resized images
  • Tells twitter the aspect ratio of the image for better resizing

This is what is adds to the HTML:
Code:
<meta property="og:description" content="Long tutorial here, gonna upload it in 4 seperate parts!  It is 1.5 hours long and will explain everything you need to know to get started using IDA Pro!
Requirements: Intermediate Knowledge of C++ and x86 Assembly"/>
<meta property="og:site_name" content="GuidedHacking How to Hack Games"/>
<meta property="og:title" content="How to Reverse Engineer with IDA Pro Disassembler"/>
<meta property="og:type" content="article"/>
<meta property="fb:app_id" content="1755543248015018"/>
<meta property="fb:admins" content="100009786466728"/>
<meta property="og:url" content="http://guidedhacking.com/showthread.php?7914-How-to-Reverse-Engineer-with-IDA-Pro-Disassembler"/>
<meta property="og:image" content="http://img.youtube.com/vi/fgMl0Uqiey8/maxresdefault.jpg"/>
<meta name="twitter:card" content="summary_large_image"/>
<meta name="twitter:site" content="@guidedhacking"/>
<meta name="twitter:image:width" content="1280"/>
<meta name="twitter:image:height" content="720"/>
Now the share looks like this:

Instead of:


Combining this with some simple social share buttons makes my social marketing campaign 2easy

I was hoping to get some feedback on my code from the pros. Currently on vb4.2.3 and vbAdvanced 4.3.0
Please don't install if you don't know what you're doing, I've tested it thoroughly but am not an expert
Attached Files
File Type: xml product-GH-SocialMediaMeta050.xml (7.3 KB, 12 views)
Reply With Quote
  #2  
Old 05-20-2016, 03:28 PM
Dave Dave is offline
 
Join Date: May 2010
Posts: 2,583
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The code looks fine. The only comment I can make about it is that you should avoid using $GLOBALS. It's bad practice to use that these days.
Reply With Quote
2 благодарности(ей) от:
GHRake, MarkFL
  #3  
Old 05-20-2016, 03:42 PM
MarkFL's Avatar
MarkFL MarkFL is offline
 
Join Date: Feb 2014
Location: St. Augustine, FL
Posts: 3,853
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I agree with Dave on both counts. I've never needed to use $GLOBALS.

But, congratulations on creating your first product. But be warned...it can be addictive.
Reply With Quote
  #4  
Old 05-22-2016, 01:16 AM
GHRake GHRake is offline
 
Join Date: Sep 2015
Location: USA
Posts: 46
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Could you fine fellas enlighten on me on how I would access $GLOBALS['threadinfo']['description']
without using $GLOBALS? Thanks in advance
Reply With Quote
  #5  
Old 05-22-2016, 01:29 AM
MarkFL's Avatar
MarkFL MarkFL is offline
 
Join Date: Feb 2014
Location: St. Augustine, FL
Posts: 3,853
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by GHRake View Post
Could you fine fellas enlighten on me on how I would access $GLOBALS['threadinfo']['description']
without using $GLOBALS? Thanks in advance
You've already declared the array "$threadinfo" global in your plugin, so you should be able to access that element with:

$threadinfo['description']
Reply With Quote
  #6  
Old 05-23-2016, 05:41 PM
GHRake GHRake is offline
 
Join Date: Sep 2015
Location: USA
Posts: 46
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by MarkFL View Post
You've already declared the array "$threadinfo" global in your plugin, so you should be able to access that element with:

$threadinfo['description']
Worked like a charm, thanks
Reply With Quote
Благодарность от:
MarkFL
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:36 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03739 seconds
  • Memory Usage 2,237KB
  • Queries Executed 12 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_code
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (6)post_thanks_box
  • (3)post_thanks_box_bit
  • (6)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (2)post_thanks_postbit
  • (6)post_thanks_postbit_info
  • (6)postbit
  • (1)postbit_attachment
  • (6)postbit_onlinestatus
  • (6)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_attachment
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete